ccjk 12.0.7 → 12.0.8
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/package.json +1 -1
- package/dist/chunks/agent-teams.mjs +0 -136
- package/dist/chunks/agent.mjs +0 -1439
- package/dist/chunks/agents.mjs +0 -3778
- package/dist/chunks/api-cli.mjs +0 -132
- package/dist/chunks/api-providers.mjs +0 -129
- package/dist/chunks/api.mjs +0 -112
- package/dist/chunks/auto-bootstrap.mjs +0 -358
- package/dist/chunks/auto-init.mjs +0 -7584
- package/dist/chunks/auto-updater.mjs +0 -410
- package/dist/chunks/banner.mjs +0 -188
- package/dist/chunks/bash.mjs +0 -187
- package/dist/chunks/boost.mjs +0 -397
- package/dist/chunks/ccjk-agents.mjs +0 -414
- package/dist/chunks/ccjk-all.mjs +0 -1028
- package/dist/chunks/ccjk-config.mjs +0 -261
- package/dist/chunks/ccjk-hooks.mjs +0 -1074
- package/dist/chunks/ccjk-mcp.mjs +0 -761
- package/dist/chunks/ccjk-setup.mjs +0 -763
- package/dist/chunks/ccjk-skills.mjs +0 -514
- package/dist/chunks/ccr.mjs +0 -98
- package/dist/chunks/ccu.mjs +0 -40
- package/dist/chunks/check-updates.mjs +0 -108
- package/dist/chunks/claude-code-config-manager.mjs +0 -750
- package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
- package/dist/chunks/claude-config.mjs +0 -236
- package/dist/chunks/claude-wrapper.mjs +0 -85
- package/dist/chunks/cleanup-migration.mjs +0 -20
- package/dist/chunks/cli-hook.mjs +0 -2285
- package/dist/chunks/cloud-sync.mjs +0 -29
- package/dist/chunks/codex-config-switch.mjs +0 -451
- package/dist/chunks/codex-provider-manager.mjs +0 -236
- package/dist/chunks/codex-uninstaller.mjs +0 -404
- package/dist/chunks/codex.mjs +0 -2077
- package/dist/chunks/commands.mjs +0 -108
- package/dist/chunks/commands2.mjs +0 -413
- package/dist/chunks/commit.mjs +0 -138
- package/dist/chunks/completion.mjs +0 -515
- package/dist/chunks/config-consolidator.mjs +0 -172
- package/dist/chunks/config-switch.mjs +0 -317
- package/dist/chunks/config.mjs +0 -379
- package/dist/chunks/config2.mjs +0 -477
- package/dist/chunks/config3.mjs +0 -470
- package/dist/chunks/constants.mjs +0 -133
- package/dist/chunks/context-loader.mjs +0 -343
- package/dist/chunks/context.mjs +0 -372
- package/dist/chunks/convoy-manager.mjs +0 -880
- package/dist/chunks/dashboard.mjs +0 -476
- package/dist/chunks/doctor.mjs +0 -964
- package/dist/chunks/evolution.mjs +0 -382
- package/dist/chunks/features.mjs +0 -698
- package/dist/chunks/fish.mjs +0 -181
- package/dist/chunks/fs-operations.mjs +0 -192
- package/dist/chunks/health-alerts.mjs +0 -304
- package/dist/chunks/health-check.mjs +0 -532
- package/dist/chunks/help.mjs +0 -340
- package/dist/chunks/hook-installer.mjs +0 -45
- package/dist/chunks/index.mjs +0 -24
- package/dist/chunks/index10.mjs +0 -1171
- package/dist/chunks/index11.mjs +0 -1008
- package/dist/chunks/index12.mjs +0 -193
- package/dist/chunks/index13.mjs +0 -218
- package/dist/chunks/index14.mjs +0 -663
- package/dist/chunks/index2.mjs +0 -19
- package/dist/chunks/index3.mjs +0 -19092
- package/dist/chunks/index4.mjs +0 -8
- package/dist/chunks/index5.mjs +0 -7600
- package/dist/chunks/index6.mjs +0 -171
- package/dist/chunks/index7.mjs +0 -3583
- package/dist/chunks/index8.mjs +0 -19
- package/dist/chunks/index9.mjs +0 -616
- package/dist/chunks/init.mjs +0 -1606
- package/dist/chunks/installer.mjs +0 -690
- package/dist/chunks/installer2.mjs +0 -179
- package/dist/chunks/interview.mjs +0 -2927
- package/dist/chunks/json-config.mjs +0 -60
- package/dist/chunks/linux.mjs +0 -3863
- package/dist/chunks/macos.mjs +0 -69
- package/dist/chunks/main.mjs +0 -635
- package/dist/chunks/manager.mjs +0 -1048
- package/dist/chunks/marketplace.mjs +0 -949
- package/dist/chunks/mcp-cli.mjs +0 -204
- package/dist/chunks/mcp-performance.mjs +0 -187
- package/dist/chunks/mcp.mjs +0 -1231
- package/dist/chunks/menu.mjs +0 -652
- package/dist/chunks/metrics-display.mjs +0 -153
- package/dist/chunks/migrator.mjs +0 -178
- package/dist/chunks/monitor.mjs +0 -1856
- package/dist/chunks/notification.mjs +0 -1864
- package/dist/chunks/onboarding.mjs +0 -385
- package/dist/chunks/package.mjs +0 -3
- package/dist/chunks/paradigm.mjs +0 -74
- package/dist/chunks/permission-manager.mjs +0 -132
- package/dist/chunks/permissions.mjs +0 -265
- package/dist/chunks/persistence-manager.mjs +0 -794
- package/dist/chunks/persistence.mjs +0 -667
- package/dist/chunks/platform.mjs +0 -391
- package/dist/chunks/plugin.mjs +0 -1936
- package/dist/chunks/powershell.mjs +0 -213
- package/dist/chunks/prompts.mjs +0 -241
- package/dist/chunks/providers.mjs +0 -260
- package/dist/chunks/quick-actions.mjs +0 -320
- package/dist/chunks/quick-provider.mjs +0 -682
- package/dist/chunks/quick-setup.mjs +0 -412
- package/dist/chunks/remote.mjs +0 -497
- package/dist/chunks/session.mjs +0 -878
- package/dist/chunks/sessions.mjs +0 -106
- package/dist/chunks/silent-updater.mjs +0 -396
- package/dist/chunks/simple-config.mjs +0 -98
- package/dist/chunks/skill.mjs +0 -117
- package/dist/chunks/skill2.mjs +0 -9003
- package/dist/chunks/skills-sync.mjs +0 -6460
- package/dist/chunks/skills.mjs +0 -567
- package/dist/chunks/slash-commands.mjs +0 -207
- package/dist/chunks/smart-defaults.mjs +0 -412
- package/dist/chunks/smart-guide.mjs +0 -194
- package/dist/chunks/startup.mjs +0 -487
- package/dist/chunks/stats.mjs +0 -410
- package/dist/chunks/status.mjs +0 -289
- package/dist/chunks/team.mjs +0 -63
- package/dist/chunks/thinking.mjs +0 -626
- package/dist/chunks/trace.mjs +0 -57
- package/dist/chunks/uninstall.mjs +0 -849
- package/dist/chunks/update.mjs +0 -167
- package/dist/chunks/upgrade-manager.mjs +0 -204
- package/dist/chunks/version-checker.mjs +0 -881
- package/dist/chunks/vim.mjs +0 -903
- package/dist/chunks/windows.mjs +0 -14
- package/dist/chunks/workflows.mjs +0 -633
- package/dist/chunks/wsl.mjs +0 -129
- package/dist/chunks/zero-config.mjs +0 -374
- package/dist/chunks/zsh.mjs +0 -182
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -2199
- package/dist/i18n/locales/en/agent-teams.json +0 -18
- package/dist/i18n/locales/en/agentBrowser.json +0 -79
- package/dist/i18n/locales/en/agents.json +0 -135
- package/dist/i18n/locales/en/api.json +0 -63
- package/dist/i18n/locales/en/ccjk-agents.json +0 -33
- package/dist/i18n/locales/en/ccjk-all.json +0 -23
- package/dist/i18n/locales/en/ccjk-skills.json +0 -22
- package/dist/i18n/locales/en/ccjk.json +0 -276
- package/dist/i18n/locales/en/ccr.json +0 -65
- package/dist/i18n/locales/en/claude-md.json +0 -73
- package/dist/i18n/locales/en/cli.json +0 -152
- package/dist/i18n/locales/en/cloud-setup.json +0 -31
- package/dist/i18n/locales/en/cloud-sync.json +0 -147
- package/dist/i18n/locales/en/cloud.json +0 -40
- package/dist/i18n/locales/en/cloudPlugins.json +0 -118
- package/dist/i18n/locales/en/codex.json +0 -127
- package/dist/i18n/locales/en/cometix.json +0 -29
- package/dist/i18n/locales/en/common.json +0 -68
- package/dist/i18n/locales/en/config.json +0 -108
- package/dist/i18n/locales/en/configuration.json +0 -226
- package/dist/i18n/locales/en/context.json +0 -85
- package/dist/i18n/locales/en/dashboard.json +0 -78
- package/dist/i18n/locales/en/errors.json +0 -26
- package/dist/i18n/locales/en/evolution.json +0 -54
- package/dist/i18n/locales/en/hooks.json +0 -74
- package/dist/i18n/locales/en/hooksSync.json +0 -133
- package/dist/i18n/locales/en/installation.json +0 -83
- package/dist/i18n/locales/en/interview.json +0 -104
- package/dist/i18n/locales/en/language.json +0 -19
- package/dist/i18n/locales/en/lsp.json +0 -78
- package/dist/i18n/locales/en/marketplace.json +0 -116
- package/dist/i18n/locales/en/mcp.json +0 -178
- package/dist/i18n/locales/en/memory.json +0 -92
- package/dist/i18n/locales/en/menu.json +0 -143
- package/dist/i18n/locales/en/multi-config.json +0 -79
- package/dist/i18n/locales/en/notification.json +0 -307
- package/dist/i18n/locales/en/permissions.json +0 -95
- package/dist/i18n/locales/en/persistence.json +0 -127
- package/dist/i18n/locales/en/plugins.json +0 -146
- package/dist/i18n/locales/en/quick-actions.json +0 -78
- package/dist/i18n/locales/en/registry.json +0 -54
- package/dist/i18n/locales/en/remote.json +0 -93
- package/dist/i18n/locales/en/sandbox.json +0 -44
- package/dist/i18n/locales/en/setup.json +0 -44
- package/dist/i18n/locales/en/shencha.json +0 -14
- package/dist/i18n/locales/en/skills.json +0 -100
- package/dist/i18n/locales/en/skillsSync.json +0 -74
- package/dist/i18n/locales/en/smartGuide.json +0 -49
- package/dist/i18n/locales/en/stats.json +0 -20
- package/dist/i18n/locales/en/subagent.json +0 -69
- package/dist/i18n/locales/en/superpowers.json +0 -117
- package/dist/i18n/locales/en/team.json +0 -7
- package/dist/i18n/locales/en/thinking.json +0 -65
- package/dist/i18n/locales/en/tools.json +0 -42
- package/dist/i18n/locales/en/uninstall.json +0 -56
- package/dist/i18n/locales/en/updater.json +0 -29
- package/dist/i18n/locales/en/vim.json +0 -169
- package/dist/i18n/locales/en/workflow.json +0 -55
- package/dist/i18n/locales/en/workspace.json +0 -108
- package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
- package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
- package/dist/i18n/locales/zh-CN/agents.json +0 -135
- package/dist/i18n/locales/zh-CN/api.json +0 -63
- package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
- package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
- package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
- package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
- package/dist/i18n/locales/zh-CN/ccr.json +0 -65
- package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
- package/dist/i18n/locales/zh-CN/cli.json +0 -152
- package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
- package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
- package/dist/i18n/locales/zh-CN/cloud.json +0 -40
- package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
- package/dist/i18n/locales/zh-CN/codex.json +0 -127
- package/dist/i18n/locales/zh-CN/cometix.json +0 -29
- package/dist/i18n/locales/zh-CN/common.json +0 -68
- package/dist/i18n/locales/zh-CN/config.json +0 -108
- package/dist/i18n/locales/zh-CN/configuration.json +0 -224
- package/dist/i18n/locales/zh-CN/context.json +0 -85
- package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
- package/dist/i18n/locales/zh-CN/errors.json +0 -26
- package/dist/i18n/locales/zh-CN/evolution.json +0 -54
- package/dist/i18n/locales/zh-CN/hooks.json +0 -74
- package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
- package/dist/i18n/locales/zh-CN/installation.json +0 -83
- package/dist/i18n/locales/zh-CN/interview.json +0 -104
- package/dist/i18n/locales/zh-CN/language.json +0 -19
- package/dist/i18n/locales/zh-CN/lsp.json +0 -78
- package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
- package/dist/i18n/locales/zh-CN/mcp.json +0 -178
- package/dist/i18n/locales/zh-CN/memory.json +0 -92
- package/dist/i18n/locales/zh-CN/menu.json +0 -143
- package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
- package/dist/i18n/locales/zh-CN/notification.json +0 -307
- package/dist/i18n/locales/zh-CN/permissions.json +0 -95
- package/dist/i18n/locales/zh-CN/persistence.json +0 -127
- package/dist/i18n/locales/zh-CN/plugins.json +0 -146
- package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
- package/dist/i18n/locales/zh-CN/registry.json +0 -54
- package/dist/i18n/locales/zh-CN/remote.json +0 -93
- package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
- package/dist/i18n/locales/zh-CN/setup.json +0 -44
- package/dist/i18n/locales/zh-CN/shencha.json +0 -14
- package/dist/i18n/locales/zh-CN/skills.json +0 -100
- package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
- package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
- package/dist/i18n/locales/zh-CN/stats.json +0 -20
- package/dist/i18n/locales/zh-CN/subagent.json +0 -69
- package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
- package/dist/i18n/locales/zh-CN/team.json +0 -7
- package/dist/i18n/locales/zh-CN/thinking.json +0 -65
- package/dist/i18n/locales/zh-CN/tools.json +0 -42
- package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
- package/dist/i18n/locales/zh-CN/updater.json +0 -29
- package/dist/i18n/locales/zh-CN/vim.json +0 -169
- package/dist/i18n/locales/zh-CN/workflow.json +0 -55
- package/dist/i18n/locales/zh-CN/workspace.json +0 -108
- package/dist/index.d.mts +0 -5295
- package/dist/index.d.ts +0 -5295
- package/dist/index.mjs +0 -4941
- package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
- package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
- package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
- package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
- package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
- package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
- package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
- package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
- package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
- package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
- package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
- package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
- package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
- package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
- package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
- package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
- package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
- package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
- package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
- package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
- package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
- package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
- package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
- package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
- package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
- package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
- package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
- package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
- package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
- package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
- package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
- package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
- package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
- package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
- package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
- package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
- package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
- package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
- package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
- package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
- package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
- package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
- package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
|
@@ -1,2451 +0,0 @@
|
|
|
1
|
-
import { c as consola } from './ccjk.UIvifqNE.mjs';
|
|
2
|
-
import { promises, existsSync } from 'node:fs';
|
|
3
|
-
import posix from '../chunks/index8.mjs';
|
|
4
|
-
import { glob } from 'tinyglobby';
|
|
5
|
-
import { p as parse } from './ccjk.BBtCGd_g.mjs';
|
|
6
|
-
|
|
7
|
-
async function pathExists$5(p) {
|
|
8
|
-
try {
|
|
9
|
-
await promises.access(p);
|
|
10
|
-
return true;
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async function readJson$1(p) {
|
|
16
|
-
const content = await promises.readFile(p, "utf-8");
|
|
17
|
-
return JSON.parse(content);
|
|
18
|
-
}
|
|
19
|
-
const logger$6 = consola.withTag("dependency-resolver");
|
|
20
|
-
async function analyzeDependencies$1(analysis, config) {
|
|
21
|
-
logger$6.info("Analyzing project dependencies");
|
|
22
|
-
if (config.analyzeTransitiveDeps) {
|
|
23
|
-
logger$6.warn(
|
|
24
|
-
'Transitive dependency analysis requested but not fully implemented. The "all" field will only contain direct dependencies. See dependency-resolver.ts for details.'
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
const projectPath = analysis.rootPath;
|
|
28
|
-
const packageManager = analysis.packageManager;
|
|
29
|
-
analysis.languages;
|
|
30
|
-
let direct = [];
|
|
31
|
-
let all = [];
|
|
32
|
-
if (packageManager === "npm" || packageManager === "yarn" || packageManager === "pnpm" || packageManager === "bun") {
|
|
33
|
-
const npmDeps = await analyzeNpmDependencies(projectPath);
|
|
34
|
-
direct = npmDeps.direct;
|
|
35
|
-
all = npmDeps.all;
|
|
36
|
-
} else if (packageManager === "pip" || packageManager === "poetry" || packageManager === "pipenv") {
|
|
37
|
-
const pythonDeps = await analyzePythonDependencies(projectPath, packageManager);
|
|
38
|
-
direct = pythonDeps.direct;
|
|
39
|
-
all = pythonDeps.all;
|
|
40
|
-
} else if (packageManager === "go") {
|
|
41
|
-
const goDeps = await analyzeGoDependencies(projectPath);
|
|
42
|
-
direct = goDeps.direct;
|
|
43
|
-
all = goDeps.all;
|
|
44
|
-
} else if (packageManager === "cargo") {
|
|
45
|
-
const rustDeps = await analyzeRustDependencies(projectPath);
|
|
46
|
-
direct = rustDeps.direct;
|
|
47
|
-
all = rustDeps.all;
|
|
48
|
-
}
|
|
49
|
-
const graph = buildDependencyGraph(all);
|
|
50
|
-
const installationPlan = generateInstallationPlan(all, packageManager);
|
|
51
|
-
const conflicts = detectConflicts(all);
|
|
52
|
-
const circularDeps = detectCircularDependencies(graph);
|
|
53
|
-
logger$6.info(`Found ${direct.length} direct dependencies, ${all.length} total`);
|
|
54
|
-
if (conflicts.length > 0) {
|
|
55
|
-
logger$6.warn(`Found ${conflicts.length} dependency conflicts`);
|
|
56
|
-
}
|
|
57
|
-
if (circularDeps.length > 0) {
|
|
58
|
-
logger$6.warn(`Found ${circularDeps.length} circular dependencies`);
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
direct,
|
|
62
|
-
all,
|
|
63
|
-
graph,
|
|
64
|
-
installationPlan,
|
|
65
|
-
conflicts,
|
|
66
|
-
circularDeps
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
async function analyzeNpmDependencies(projectPath) {
|
|
70
|
-
const packageJsonPath = posix.join(projectPath, "package.json");
|
|
71
|
-
if (!await pathExists$5(packageJsonPath)) {
|
|
72
|
-
return { direct: [], all: [] };
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const packageJson = await readJson$1(packageJsonPath);
|
|
76
|
-
const direct = [];
|
|
77
|
-
const processDeps = (deps2, isDev, isPeer) => {
|
|
78
|
-
if (!deps2)
|
|
79
|
-
return [];
|
|
80
|
-
return Object.entries(deps2).map(([name, version]) => ({
|
|
81
|
-
name,
|
|
82
|
-
version,
|
|
83
|
-
type: isDev ? "dev" : isPeer ? "peer" : "runtime",
|
|
84
|
-
isDev,
|
|
85
|
-
isPeer,
|
|
86
|
-
isOptional: false
|
|
87
|
-
}));
|
|
88
|
-
};
|
|
89
|
-
const deps = processDeps(packageJson.dependencies, false, false);
|
|
90
|
-
const devDeps = processDeps(packageJson.devDependencies, true, false);
|
|
91
|
-
const peerDeps = processDeps(packageJson.peerDependencies, false, true);
|
|
92
|
-
const optionalDeps = processDeps(packageJson.optionalDependencies, false, false).map((d) => ({
|
|
93
|
-
...d,
|
|
94
|
-
isOptional: true,
|
|
95
|
-
type: "optional"
|
|
96
|
-
}));
|
|
97
|
-
direct.push(...deps, ...devDeps, ...peerDeps, ...optionalDeps);
|
|
98
|
-
const all = [...direct];
|
|
99
|
-
return { direct, all };
|
|
100
|
-
} catch (error) {
|
|
101
|
-
logger$6.warn("Failed to analyze npm dependencies:", error);
|
|
102
|
-
return { direct: [], all: [] };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function analyzePythonDependencies(projectPath, packageManager) {
|
|
106
|
-
const direct = [];
|
|
107
|
-
const all = [];
|
|
108
|
-
if (packageManager === "poetry") {
|
|
109
|
-
const pyprojectPath = posix.join(projectPath, "pyproject.toml");
|
|
110
|
-
if (await pathExists$5(pyprojectPath)) {
|
|
111
|
-
try {
|
|
112
|
-
const { parse } = await import('../chunks/index6.mjs');
|
|
113
|
-
const content = await promises.readFile(pyprojectPath, "utf-8");
|
|
114
|
-
const pyproject = parse(content);
|
|
115
|
-
const deps = pyproject.tool?.poetry?.dependencies || {};
|
|
116
|
-
const devDeps = pyproject.tool?.poetry?.["dev-dependencies"] || {};
|
|
117
|
-
for (const [name, version] of Object.entries(deps)) {
|
|
118
|
-
direct.push({
|
|
119
|
-
name,
|
|
120
|
-
version: typeof version === "string" ? version : "latest",
|
|
121
|
-
type: "runtime",
|
|
122
|
-
isDev: false,
|
|
123
|
-
isPeer: false,
|
|
124
|
-
isOptional: false
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
for (const [name, version] of Object.entries(devDeps)) {
|
|
128
|
-
direct.push({
|
|
129
|
-
name,
|
|
130
|
-
version: typeof version === "string" ? version : "latest",
|
|
131
|
-
type: "dev",
|
|
132
|
-
isDev: true,
|
|
133
|
-
isPeer: false,
|
|
134
|
-
isOptional: false
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
} catch (error) {
|
|
138
|
-
logger$6.warn("Failed to parse pyproject.toml:", error);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} else if (packageManager === "pipenv") {
|
|
142
|
-
const pipfilePath = posix.join(projectPath, "Pipfile");
|
|
143
|
-
if (await pathExists$5(pipfilePath)) {
|
|
144
|
-
try {
|
|
145
|
-
const { parse } = await import('../chunks/index6.mjs');
|
|
146
|
-
const content = await promises.readFile(pipfilePath, "utf-8");
|
|
147
|
-
const pipfile = parse(content);
|
|
148
|
-
const deps = pipfile.packages || {};
|
|
149
|
-
const devDeps = pipfile["dev-packages"] || {};
|
|
150
|
-
for (const [name, version] of Object.entries(deps)) {
|
|
151
|
-
direct.push({
|
|
152
|
-
name,
|
|
153
|
-
version: typeof version === "string" ? version : "latest",
|
|
154
|
-
type: "runtime",
|
|
155
|
-
isDev: false,
|
|
156
|
-
isPeer: false,
|
|
157
|
-
isOptional: false
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
for (const [name, version] of Object.entries(devDeps)) {
|
|
161
|
-
direct.push({
|
|
162
|
-
name,
|
|
163
|
-
version: typeof version === "string" ? version : "latest",
|
|
164
|
-
type: "dev",
|
|
165
|
-
isDev: true,
|
|
166
|
-
isPeer: false,
|
|
167
|
-
isOptional: false
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
} catch (error) {
|
|
171
|
-
logger$6.warn("Failed to parse Pipfile:", error);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
const requirementsPath = posix.join(projectPath, "requirements.txt");
|
|
176
|
-
if (await pathExists$5(requirementsPath)) {
|
|
177
|
-
try {
|
|
178
|
-
const content = await promises.readFile(requirementsPath, "utf-8");
|
|
179
|
-
const lines = content.split("\n");
|
|
180
|
-
for (const line of lines) {
|
|
181
|
-
const trimmed = line.trim();
|
|
182
|
-
if (trimmed && !trimmed.startsWith("#")) {
|
|
183
|
-
const match = trimmed.match(/^([\w-]+)([[~=><].*)?$/);
|
|
184
|
-
if (match) {
|
|
185
|
-
direct.push({
|
|
186
|
-
name: match[1],
|
|
187
|
-
version: match[2] || "latest",
|
|
188
|
-
type: "runtime",
|
|
189
|
-
isDev: false,
|
|
190
|
-
isPeer: false,
|
|
191
|
-
isOptional: false
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
} catch (error) {
|
|
197
|
-
logger$6.warn("Failed to parse requirements.txt:", error);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
all.push(...direct);
|
|
202
|
-
return { direct, all };
|
|
203
|
-
}
|
|
204
|
-
async function analyzeGoDependencies(projectPath) {
|
|
205
|
-
const goModPath = posix.join(projectPath, "go.mod");
|
|
206
|
-
if (!await pathExists$5(goModPath)) {
|
|
207
|
-
return { direct: [], all: [] };
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
const content = await promises.readFile(goModPath, "utf-8");
|
|
211
|
-
const lines = content.split("\n");
|
|
212
|
-
const direct = [];
|
|
213
|
-
let inRequireBlock = false;
|
|
214
|
-
for (const line of lines) {
|
|
215
|
-
const trimmed = line.trim();
|
|
216
|
-
if (trimmed.startsWith("require (")) {
|
|
217
|
-
inRequireBlock = true;
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (inRequireBlock && trimmed === ")") {
|
|
221
|
-
inRequireBlock = false;
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (trimmed.startsWith("require ") || inRequireBlock) {
|
|
225
|
-
const parts = trimmed.split(/\s+/);
|
|
226
|
-
if (parts.length >= 2) {
|
|
227
|
-
const name = parts[0].replace("require ", "");
|
|
228
|
-
const version = parts[1];
|
|
229
|
-
direct.push({
|
|
230
|
-
name,
|
|
231
|
-
version,
|
|
232
|
-
type: "runtime",
|
|
233
|
-
isDev: false,
|
|
234
|
-
isPeer: false,
|
|
235
|
-
isOptional: false
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const all = [...direct];
|
|
241
|
-
return { direct, all };
|
|
242
|
-
} catch (error) {
|
|
243
|
-
logger$6.warn("Failed to analyze Go dependencies:", error);
|
|
244
|
-
return { direct: [], all: [] };
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
async function analyzeRustDependencies(projectPath) {
|
|
248
|
-
const cargoTomlPath = posix.join(projectPath, "Cargo.toml");
|
|
249
|
-
if (!await pathExists$5(cargoTomlPath)) {
|
|
250
|
-
return { direct: [], all: [] };
|
|
251
|
-
}
|
|
252
|
-
try {
|
|
253
|
-
const { parse } = await import('../chunks/index6.mjs');
|
|
254
|
-
const content = await promises.readFile(cargoTomlPath, "utf-8");
|
|
255
|
-
const cargoToml = parse(content);
|
|
256
|
-
const direct = [];
|
|
257
|
-
const processDeps = (deps2, isDev) => {
|
|
258
|
-
if (!deps2)
|
|
259
|
-
return [];
|
|
260
|
-
return Object.entries(deps2).map(([name, version]) => ({
|
|
261
|
-
name,
|
|
262
|
-
version: typeof version === "string" ? version : version?.version || "latest",
|
|
263
|
-
type: isDev ? "dev" : "runtime",
|
|
264
|
-
isDev,
|
|
265
|
-
isPeer: false,
|
|
266
|
-
isOptional: false
|
|
267
|
-
}));
|
|
268
|
-
};
|
|
269
|
-
const deps = processDeps(cargoToml.dependencies, false);
|
|
270
|
-
const devDeps = processDeps(cargoToml["dev-dependencies"], true);
|
|
271
|
-
const buildDeps = processDeps(cargoToml["build-dependencies"], false);
|
|
272
|
-
direct.push(...deps, ...devDeps, ...buildDeps);
|
|
273
|
-
const all = [...direct];
|
|
274
|
-
return { direct, all };
|
|
275
|
-
} catch (error) {
|
|
276
|
-
logger$6.warn("Failed to analyze Rust dependencies:", error);
|
|
277
|
-
return { direct: [], all: [] };
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function buildDependencyGraph(dependencies) {
|
|
281
|
-
const graph = /* @__PURE__ */ new Map();
|
|
282
|
-
for (const dep of dependencies) {
|
|
283
|
-
graph.set(dep.name, []);
|
|
284
|
-
}
|
|
285
|
-
return graph;
|
|
286
|
-
}
|
|
287
|
-
function generateInstallationPlan(dependencies, packageManager) {
|
|
288
|
-
const order = [...dependencies];
|
|
289
|
-
const runtime = order.filter((d) => d.type === "runtime");
|
|
290
|
-
order.filter((d) => d.type === "dev");
|
|
291
|
-
order.filter((d) => d.type === "peer");
|
|
292
|
-
order.filter((d) => d.type === "optional");
|
|
293
|
-
const parallelizable = runtime.length;
|
|
294
|
-
const commands = generateInstallationCommands(packageManager);
|
|
295
|
-
return {
|
|
296
|
-
order,
|
|
297
|
-
total: dependencies.length,
|
|
298
|
-
parallelizable,
|
|
299
|
-
commands
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
function generateInstallationCommands(packageManager) {
|
|
303
|
-
if (!packageManager) {
|
|
304
|
-
return {
|
|
305
|
-
installAll: 'echo "Unknown package manager"',
|
|
306
|
-
installPackage: () => 'echo "Unknown package manager"',
|
|
307
|
-
installDev: 'echo "Unknown package manager"',
|
|
308
|
-
add: () => 'echo "Unknown package manager"'
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
const commands = {
|
|
312
|
-
npm: {
|
|
313
|
-
installAll: "npm install",
|
|
314
|
-
installPackage: (name, version) => `npm install ${name}${version ? `@${version}` : ""}`,
|
|
315
|
-
installDev: "npm install --only=dev",
|
|
316
|
-
add: (name, isDev) => isDev ? `npm install -D ${name}` : `npm install ${name}`
|
|
317
|
-
},
|
|
318
|
-
yarn: {
|
|
319
|
-
installAll: "yarn install",
|
|
320
|
-
installPackage: (name, version) => `yarn add ${name}${version ? `@${version}` : ""}`,
|
|
321
|
-
installDev: "yarn install --dev",
|
|
322
|
-
add: (name, isDev) => isDev ? `yarn add -D ${name}` : `yarn add ${name}`
|
|
323
|
-
},
|
|
324
|
-
pnpm: {
|
|
325
|
-
installAll: "pnpm install",
|
|
326
|
-
installPackage: (name, version) => `pnpm add ${name}${version ? `@${version}` : ""}`,
|
|
327
|
-
installDev: "pnpm install --dev",
|
|
328
|
-
add: (name, isDev) => isDev ? `pnpm add -D ${name}` : `pnpm add ${name}`
|
|
329
|
-
},
|
|
330
|
-
bun: {
|
|
331
|
-
installAll: "bun install",
|
|
332
|
-
installPackage: (name, version) => `bun add ${name}${version ? `@${version}` : ""}`,
|
|
333
|
-
installDev: "bun install --dev",
|
|
334
|
-
add: (name, isDev) => isDev ? `bun add -d ${name}` : `bun add ${name}`
|
|
335
|
-
},
|
|
336
|
-
pip: {
|
|
337
|
-
installAll: "pip install -r requirements.txt",
|
|
338
|
-
installPackage: (name, version) => `pip install ${name}${version ? version.replace(/[*=]/, "==") : ""}`,
|
|
339
|
-
installDev: "pip install -r requirements-dev.txt",
|
|
340
|
-
add: (name) => `pip install ${name}`
|
|
341
|
-
},
|
|
342
|
-
poetry: {
|
|
343
|
-
installAll: "poetry install",
|
|
344
|
-
installPackage: (name, version) => `poetry add ${name}${version ? `=${version}` : ""}`,
|
|
345
|
-
installDev: "poetry install --with dev",
|
|
346
|
-
add: (name, isDev) => isDev ? `poetry add --group dev ${name}` : `poetry add ${name}`
|
|
347
|
-
},
|
|
348
|
-
pipenv: {
|
|
349
|
-
installAll: "pipenv install",
|
|
350
|
-
installPackage: (name, version) => `pipenv install ${name}${version ? `==${version}` : ""}`,
|
|
351
|
-
installDev: "pipenv install --dev",
|
|
352
|
-
add: (name, isDev) => isDev ? `pipenv install --dev ${name}` : `pipenv install ${name}`
|
|
353
|
-
},
|
|
354
|
-
go: {
|
|
355
|
-
installAll: "go mod download",
|
|
356
|
-
installPackage: (name) => `go get ${name}`,
|
|
357
|
-
installDev: "go mod download",
|
|
358
|
-
add: (name) => `go get ${name}`
|
|
359
|
-
},
|
|
360
|
-
cargo: {
|
|
361
|
-
installAll: "cargo build",
|
|
362
|
-
installPackage: (name, version) => `cargo add ${name}${version ? ` --vers ${version}` : ""}`,
|
|
363
|
-
installDev: "cargo build",
|
|
364
|
-
add: (name) => `cargo add ${name}`
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
return commands[packageManager] || commands.npm;
|
|
368
|
-
}
|
|
369
|
-
function detectConflicts(dependencies, _graph) {
|
|
370
|
-
const conflicts = [];
|
|
371
|
-
const versionMap = /* @__PURE__ */ new Map();
|
|
372
|
-
for (const dep of dependencies) {
|
|
373
|
-
if (!versionMap.has(dep.name)) {
|
|
374
|
-
versionMap.set(dep.name, /* @__PURE__ */ new Set());
|
|
375
|
-
}
|
|
376
|
-
versionMap.get(dep.name).add(dep.version);
|
|
377
|
-
}
|
|
378
|
-
for (const [name, versions] of versionMap) {
|
|
379
|
-
if (versions.size > 1) {
|
|
380
|
-
conflicts.push({
|
|
381
|
-
package: name,
|
|
382
|
-
versions: Array.from(versions),
|
|
383
|
-
requiredBy: [name],
|
|
384
|
-
severity: "warning"
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return conflicts;
|
|
389
|
-
}
|
|
390
|
-
function detectCircularDependencies(graph) {
|
|
391
|
-
const circular = [];
|
|
392
|
-
const visited = /* @__PURE__ */ new Set();
|
|
393
|
-
const recStack = /* @__PURE__ */ new Set();
|
|
394
|
-
const path2 = [];
|
|
395
|
-
const dfs = (node) => {
|
|
396
|
-
visited.add(node);
|
|
397
|
-
recStack.add(node);
|
|
398
|
-
path2.push(node);
|
|
399
|
-
const neighbors = graph.get(node) || [];
|
|
400
|
-
for (const neighbor of neighbors) {
|
|
401
|
-
if (!visited.has(neighbor.name)) {
|
|
402
|
-
if (dfs(neighbor.name)) {
|
|
403
|
-
return true;
|
|
404
|
-
}
|
|
405
|
-
} else if (recStack.has(neighbor.name)) {
|
|
406
|
-
const cycleStart = path2.indexOf(neighbor.name);
|
|
407
|
-
const cycle = path2.slice(cycleStart).concat(neighbor.name);
|
|
408
|
-
circular.push(cycle);
|
|
409
|
-
return true;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
path2.pop();
|
|
413
|
-
recStack.delete(node);
|
|
414
|
-
return false;
|
|
415
|
-
};
|
|
416
|
-
for (const node of graph.keys()) {
|
|
417
|
-
if (!visited.has(node)) {
|
|
418
|
-
dfs(node);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return circular;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
async function pathExists$4(p) {
|
|
425
|
-
try {
|
|
426
|
-
await promises.access(p);
|
|
427
|
-
return true;
|
|
428
|
-
} catch {
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
const logger$5 = consola.withTag("go-analyzer");
|
|
433
|
-
const FRAMEWORK_PATTERNS$3 = {
|
|
434
|
-
gin: {
|
|
435
|
-
imports: ["github.com/gin-gonic/gin"],
|
|
436
|
-
indicators: ["gin.Default()", "gin.Context"]
|
|
437
|
-
},
|
|
438
|
-
echo: {
|
|
439
|
-
imports: ["github.com/labstack/echo/v4"],
|
|
440
|
-
indicators: ["echo.New()", "echo.Context"]
|
|
441
|
-
},
|
|
442
|
-
fiber: {
|
|
443
|
-
imports: ["github.com/gofiber/fiber/v2"],
|
|
444
|
-
indicators: ["fiber.New()", "fiber.Ctx"]
|
|
445
|
-
},
|
|
446
|
-
chi: {
|
|
447
|
-
imports: ["github.com/go-chi/chi/v5"],
|
|
448
|
-
indicators: ["chi.NewRouter()", "chi.Router"]
|
|
449
|
-
},
|
|
450
|
-
mux: {
|
|
451
|
-
imports: ["github.com/gorilla/mux"],
|
|
452
|
-
indicators: ["mux.NewRouter()", "mux.Router"]
|
|
453
|
-
},
|
|
454
|
-
httprouter: {
|
|
455
|
-
imports: ["github.com/julienschmidt/httprouter"],
|
|
456
|
-
indicators: ["httprouter.New()", "httprouter.Params"]
|
|
457
|
-
},
|
|
458
|
-
fasthttp: {
|
|
459
|
-
imports: ["github.com/valyala/fasthttp"],
|
|
460
|
-
indicators: ["fasthttp.Server", "fasthttp.RequestHandler"]
|
|
461
|
-
},
|
|
462
|
-
grpc: {
|
|
463
|
-
imports: ["google.golang.org/grpc"],
|
|
464
|
-
indicators: ["grpc.NewServer()", "grpc.Dial"]
|
|
465
|
-
},
|
|
466
|
-
protobuf: {
|
|
467
|
-
imports: ["google.golang.org/protobuf"],
|
|
468
|
-
indicators: [".proto", "proto.Marshal"]
|
|
469
|
-
},
|
|
470
|
-
gorm: {
|
|
471
|
-
imports: ["gorm.io/gorm"],
|
|
472
|
-
indicators: ["gorm.Open", "gorm.DB"]
|
|
473
|
-
},
|
|
474
|
-
sql: {
|
|
475
|
-
imports: ["database/sql"],
|
|
476
|
-
indicators: ["sql.Open", "sql.DB"]
|
|
477
|
-
},
|
|
478
|
-
ent: {
|
|
479
|
-
imports: ["entgo.io/ent"],
|
|
480
|
-
indicators: ["ent.Client", "ent.Schema"]
|
|
481
|
-
},
|
|
482
|
-
cobra: {
|
|
483
|
-
imports: ["github.com/spf13/cobra"],
|
|
484
|
-
indicators: ["cobra.Command", "cobra.Execute"]
|
|
485
|
-
},
|
|
486
|
-
viper: {
|
|
487
|
-
imports: ["github.com/spf13/viper"],
|
|
488
|
-
indicators: ["viper.New", "viper.Get"]
|
|
489
|
-
},
|
|
490
|
-
testify: {
|
|
491
|
-
imports: ["github.com/stretchr/testify"],
|
|
492
|
-
indicators: ["assert.Equal", "require.NoError"]
|
|
493
|
-
},
|
|
494
|
-
mock: {
|
|
495
|
-
imports: ["github.com/golang/mock"],
|
|
496
|
-
indicators: ["gomock.Controller", "mockgen"]
|
|
497
|
-
},
|
|
498
|
-
redis: {
|
|
499
|
-
imports: ["github.com/redis/go-redis/v9"],
|
|
500
|
-
indicators: ["redis.NewClient", "redis.Client"]
|
|
501
|
-
},
|
|
502
|
-
mongo: {
|
|
503
|
-
imports: ["go.mongodb.org/mongo-driver"],
|
|
504
|
-
indicators: ["mongo.Connect", "mongo.Database"]
|
|
505
|
-
},
|
|
506
|
-
prometheus: {
|
|
507
|
-
imports: ["github.com/prometheus/client_golang"],
|
|
508
|
-
indicators: ["prometheus.Counter", "promhttp.Handler"]
|
|
509
|
-
},
|
|
510
|
-
jaeger: {
|
|
511
|
-
imports: ["github.com/uber/jaeger-client-go"],
|
|
512
|
-
indicators: ["jaeger.NewTracer", "jaeger.Config"]
|
|
513
|
-
},
|
|
514
|
-
kubernetes: {
|
|
515
|
-
imports: ["k8s.io/client-go"],
|
|
516
|
-
indicators: ["kubernetes.Clientset", "k8s.io"]
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
async function analyzeGoProject(projectPath, files, _languages) {
|
|
520
|
-
logger$5.info("Analyzing Go project");
|
|
521
|
-
const frameworks = [];
|
|
522
|
-
const goModPath = posix.join(projectPath, "go.mod");
|
|
523
|
-
let _goMod = null;
|
|
524
|
-
try {
|
|
525
|
-
if (await pathExists$4(goModPath)) {
|
|
526
|
-
const content = await promises.readFile(goModPath, "utf-8");
|
|
527
|
-
_goMod = parseGoMod(content);
|
|
528
|
-
}
|
|
529
|
-
} catch (error) {
|
|
530
|
-
logger$5.warn("Failed to read go.mod:", error);
|
|
531
|
-
}
|
|
532
|
-
const imports = await scanGoImports(projectPath, files);
|
|
533
|
-
for (const [frameworkName, patterns] of Object.entries(FRAMEWORK_PATTERNS$3)) {
|
|
534
|
-
const evidence = [];
|
|
535
|
-
let confidence = 0;
|
|
536
|
-
for (const importPath of patterns.imports) {
|
|
537
|
-
if (imports[importPath]) {
|
|
538
|
-
evidence.push(`Found import: ${importPath}`);
|
|
539
|
-
confidence += 0.5;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
for (const indicator of patterns.indicators) {
|
|
543
|
-
const filesWithIndicator = Object.values(imports).flat();
|
|
544
|
-
if (filesWithIndicator.some((f) => f.includes(indicator))) {
|
|
545
|
-
evidence.push(`Found pattern: ${indicator}`);
|
|
546
|
-
confidence += 0.3;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
if (confidence > 0) {
|
|
550
|
-
frameworks.push({
|
|
551
|
-
name: frameworkName,
|
|
552
|
-
category: getFrameworkCategory$3(frameworkName),
|
|
553
|
-
confidence: Math.min(confidence, 1),
|
|
554
|
-
evidence
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
await detectAdditionalPatterns$3(projectPath, files, frameworks, imports);
|
|
559
|
-
frameworks.sort((a, b) => b.confidence - a.confidence);
|
|
560
|
-
logger$5.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
|
|
561
|
-
return frameworks;
|
|
562
|
-
}
|
|
563
|
-
function parseGoMod(content) {
|
|
564
|
-
const result = {
|
|
565
|
-
requires: {}
|
|
566
|
-
};
|
|
567
|
-
const lines = content.split("\n");
|
|
568
|
-
for (const line of lines) {
|
|
569
|
-
const trimmed = line.trim();
|
|
570
|
-
if (trimmed.startsWith("module")) {
|
|
571
|
-
result.module = trimmed.split(" ")[1];
|
|
572
|
-
} else if (trimmed.startsWith("go")) {
|
|
573
|
-
result.go = trimmed.split(" ")[1];
|
|
574
|
-
} else if (trimmed.startsWith("require")) {
|
|
575
|
-
const parts = trimmed.split(" ");
|
|
576
|
-
if (parts.length >= 3) {
|
|
577
|
-
result.requires[parts[1]] = parts[2];
|
|
578
|
-
}
|
|
579
|
-
} else if (trimmed.includes(" ")) {
|
|
580
|
-
const parts = trimmed.split(" ");
|
|
581
|
-
if (parts.length >= 2 && !trimmed.startsWith("//")) {
|
|
582
|
-
result.requires[parts[0]] = parts[1];
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return result;
|
|
587
|
-
}
|
|
588
|
-
async function scanGoImports(projectPath, files) {
|
|
589
|
-
const imports = {};
|
|
590
|
-
const goFiles = files.filter((f) => f.endsWith(".go"));
|
|
591
|
-
for (const file of goFiles) {
|
|
592
|
-
try {
|
|
593
|
-
const content = await promises.readFile(posix.join(projectPath, file), "utf-8");
|
|
594
|
-
const fileImports = extractGoImports(content);
|
|
595
|
-
for (const importPath of fileImports) {
|
|
596
|
-
if (!imports[importPath]) {
|
|
597
|
-
imports[importPath] = [];
|
|
598
|
-
}
|
|
599
|
-
imports[importPath].push(file);
|
|
600
|
-
}
|
|
601
|
-
} catch (error) {
|
|
602
|
-
logger$5.warn(`Failed to read ${file}:`, error);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
return imports;
|
|
606
|
-
}
|
|
607
|
-
function extractGoImports(content) {
|
|
608
|
-
const imports = [];
|
|
609
|
-
const importRegex = /import\s+(?:\(\s*([\s\S]*?)\s*\)|(["`][^"`]+["`]))/g;
|
|
610
|
-
let match;
|
|
611
|
-
while ((match = importRegex.exec(content)) !== null) {
|
|
612
|
-
const importBlock = match[1] || match[2];
|
|
613
|
-
if (importBlock) {
|
|
614
|
-
const singleImportRegex = /["`]([^"`]+)["`]/g;
|
|
615
|
-
let importMatch;
|
|
616
|
-
while ((importMatch = singleImportRegex.exec(importBlock)) !== null) {
|
|
617
|
-
imports.push(importMatch[1]);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
return imports;
|
|
622
|
-
}
|
|
623
|
-
function getFrameworkCategory$3(framework) {
|
|
624
|
-
const categories = {
|
|
625
|
-
web: [
|
|
626
|
-
"gin",
|
|
627
|
-
"echo",
|
|
628
|
-
"fiber",
|
|
629
|
-
"chi",
|
|
630
|
-
"mux",
|
|
631
|
-
"httprouter",
|
|
632
|
-
"fasthttp"
|
|
633
|
-
],
|
|
634
|
-
rpc: ["grpc", "protobuf"],
|
|
635
|
-
database: ["gorm", "sql", "ent"],
|
|
636
|
-
cli: ["cobra", "viper"],
|
|
637
|
-
testing: ["testify", "mock"],
|
|
638
|
-
cache: ["redis"],
|
|
639
|
-
database2: ["mongo"],
|
|
640
|
-
monitoring: ["prometheus", "jaeger"],
|
|
641
|
-
infrastructure: ["kubernetes"]
|
|
642
|
-
};
|
|
643
|
-
for (const [category, frameworks] of Object.entries(categories)) {
|
|
644
|
-
if (frameworks.includes(framework)) {
|
|
645
|
-
return category;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
return "other";
|
|
649
|
-
}
|
|
650
|
-
async function detectAdditionalPatterns$3(projectPath, files, frameworks, imports) {
|
|
651
|
-
const goModPath = posix.join(projectPath, "go.mod");
|
|
652
|
-
if (files.includes("go.mod") && await pathExists$4(goModPath)) {
|
|
653
|
-
try {
|
|
654
|
-
const content = await promises.readFile(goModPath, "utf-8");
|
|
655
|
-
const goVersionMatch = content.match(/^go\s+(\d+\.\d+)/m);
|
|
656
|
-
if (goVersionMatch) {
|
|
657
|
-
frameworks.push({
|
|
658
|
-
name: "go",
|
|
659
|
-
category: "language",
|
|
660
|
-
version: goVersionMatch[1],
|
|
661
|
-
confidence: 0.9,
|
|
662
|
-
evidence: ["Found go.mod"]
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
} catch (error) {
|
|
666
|
-
logger$5.warn("Failed to read go.mod:", error);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
const dockerFiles = ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"];
|
|
670
|
-
for (const file of dockerFiles) {
|
|
671
|
-
if (files.includes(file)) {
|
|
672
|
-
frameworks.push({
|
|
673
|
-
name: "docker",
|
|
674
|
-
category: "deployment",
|
|
675
|
-
confidence: 0.9,
|
|
676
|
-
evidence: [`Found ${file}`]
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
if (files.some((f) => f.endsWith("_test.go"))) {
|
|
681
|
-
frameworks.push({
|
|
682
|
-
name: "testing",
|
|
683
|
-
category: "testing",
|
|
684
|
-
confidence: 0.7,
|
|
685
|
-
evidence: ["Found test files"]
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
const buildFiles = {
|
|
689
|
-
"Makefile": "make",
|
|
690
|
-
"Dockerfile": "docker",
|
|
691
|
-
".goreleaser.yml": "goreleaser",
|
|
692
|
-
".goreleaser.yaml": "goreleaser"
|
|
693
|
-
};
|
|
694
|
-
for (const [file, tool] of Object.entries(buildFiles)) {
|
|
695
|
-
if (files.includes(file)) {
|
|
696
|
-
frameworks.push({
|
|
697
|
-
name: tool,
|
|
698
|
-
category: "build",
|
|
699
|
-
confidence: 0.8,
|
|
700
|
-
evidence: [`Found ${file}`]
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
const lintingTools = [
|
|
705
|
-
"github.com/golangci/golangci-lint",
|
|
706
|
-
"golang.org/x/lint",
|
|
707
|
-
"honnef.co/go/tools"
|
|
708
|
-
];
|
|
709
|
-
for (const tool of lintingTools) {
|
|
710
|
-
if (imports[tool]) {
|
|
711
|
-
frameworks.push({
|
|
712
|
-
name: "golangci-lint",
|
|
713
|
-
category: "linting",
|
|
714
|
-
confidence: 0.8,
|
|
715
|
-
evidence: [`Found ${tool} import`]
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
const ciFiles = {
|
|
720
|
-
".github/workflows": "github-actions",
|
|
721
|
-
".gitlab-ci.yml": "gitlab-ci",
|
|
722
|
-
"Jenkinsfile": "jenkins",
|
|
723
|
-
".travis.yml": "travis-ci"
|
|
724
|
-
};
|
|
725
|
-
for (const [file, tool] of Object.entries(ciFiles)) {
|
|
726
|
-
if (files.includes(file) || files.some((f) => f.startsWith(file))) {
|
|
727
|
-
frameworks.push({
|
|
728
|
-
name: tool,
|
|
729
|
-
category: "ci-cd",
|
|
730
|
-
confidence: 0.8,
|
|
731
|
-
evidence: [`Found ${file}`]
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
if (files.some((f) => f.endsWith(".proto"))) {
|
|
736
|
-
frameworks.push({
|
|
737
|
-
name: "protobuf",
|
|
738
|
-
category: "rpc",
|
|
739
|
-
confidence: 0.9,
|
|
740
|
-
evidence: ["Found .proto files"]
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
const goWorkPath = posix.join(projectPath, "go.work");
|
|
744
|
-
if (files.includes("go.work") && await pathExists$4(goWorkPath)) {
|
|
745
|
-
frameworks.push({
|
|
746
|
-
name: "workspace",
|
|
747
|
-
category: "workspace",
|
|
748
|
-
confidence: 0.9,
|
|
749
|
-
evidence: ["Found go.work"]
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
if (files.includes("vendor/") || files.some((f) => f.startsWith("vendor/"))) {
|
|
753
|
-
frameworks.push({
|
|
754
|
-
name: "vendor",
|
|
755
|
-
category: "dependency",
|
|
756
|
-
confidence: 0.8,
|
|
757
|
-
evidence: ["Found vendor directory"]
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
async function pathExists$3(p) {
|
|
763
|
-
try {
|
|
764
|
-
await promises.access(p);
|
|
765
|
-
return true;
|
|
766
|
-
} catch {
|
|
767
|
-
return false;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
const logger$4 = consola.withTag("python-analyzer");
|
|
771
|
-
const FRAMEWORK_PATTERNS$2 = {
|
|
772
|
-
"django": {
|
|
773
|
-
files: ["manage.py", "settings.py"],
|
|
774
|
-
dependencies: ["django"],
|
|
775
|
-
indicators: ["manage.py", "wsgi.py", "asgi.py", "settings/", "templates/", "static/"]
|
|
776
|
-
},
|
|
777
|
-
"fastapi": {
|
|
778
|
-
files: ["main.py"],
|
|
779
|
-
dependencies: ["fastapi"],
|
|
780
|
-
indicators: ["main.py", "app/", "api/", "routers/"]
|
|
781
|
-
},
|
|
782
|
-
"flask": {
|
|
783
|
-
files: ["app.py", "wsgi.py"],
|
|
784
|
-
dependencies: ["flask"],
|
|
785
|
-
indicators: ["app.py", "app/", "templates/", "static/"]
|
|
786
|
-
},
|
|
787
|
-
"tornado": {
|
|
788
|
-
files: [],
|
|
789
|
-
dependencies: ["tornado"],
|
|
790
|
-
indicators: ["tornado", "handlers/"]
|
|
791
|
-
},
|
|
792
|
-
"sanic": {
|
|
793
|
-
files: [],
|
|
794
|
-
dependencies: ["sanic"],
|
|
795
|
-
indicators: ["sanic"]
|
|
796
|
-
},
|
|
797
|
-
"quart": {
|
|
798
|
-
files: [],
|
|
799
|
-
dependencies: ["quart"],
|
|
800
|
-
indicators: ["quart"]
|
|
801
|
-
},
|
|
802
|
-
"falcon": {
|
|
803
|
-
files: [],
|
|
804
|
-
dependencies: ["falcon"],
|
|
805
|
-
indicators: ["falcon"]
|
|
806
|
-
},
|
|
807
|
-
"bottle": {
|
|
808
|
-
files: [],
|
|
809
|
-
dependencies: ["bottle"],
|
|
810
|
-
indicators: ["bottle"]
|
|
811
|
-
},
|
|
812
|
-
"pyramid": {
|
|
813
|
-
files: ["development.ini", "production.ini"],
|
|
814
|
-
dependencies: ["pyramid"],
|
|
815
|
-
indicators: ["development.ini", "production.ini"]
|
|
816
|
-
},
|
|
817
|
-
"starlette": {
|
|
818
|
-
files: [],
|
|
819
|
-
dependencies: ["starlette"],
|
|
820
|
-
indicators: ["starlette"]
|
|
821
|
-
},
|
|
822
|
-
"celery": {
|
|
823
|
-
files: ["celery.py"],
|
|
824
|
-
dependencies: ["celery"],
|
|
825
|
-
indicators: ["celery.py", "tasks.py", "celeryconfig.py"]
|
|
826
|
-
},
|
|
827
|
-
"pandas": {
|
|
828
|
-
files: [],
|
|
829
|
-
dependencies: ["pandas"],
|
|
830
|
-
indicators: ["pandas"]
|
|
831
|
-
},
|
|
832
|
-
"numpy": {
|
|
833
|
-
files: [],
|
|
834
|
-
dependencies: ["numpy"],
|
|
835
|
-
indicators: ["numpy"]
|
|
836
|
-
},
|
|
837
|
-
"scikit-learn": {
|
|
838
|
-
files: [],
|
|
839
|
-
dependencies: ["scikit-learn"],
|
|
840
|
-
indicators: ["sklearn"]
|
|
841
|
-
},
|
|
842
|
-
"tensorflow": {
|
|
843
|
-
files: [],
|
|
844
|
-
dependencies: ["tensorflow"],
|
|
845
|
-
indicators: ["tensorflow"]
|
|
846
|
-
},
|
|
847
|
-
"pytorch": {
|
|
848
|
-
files: [],
|
|
849
|
-
dependencies: ["torch"],
|
|
850
|
-
indicators: ["torch"]
|
|
851
|
-
},
|
|
852
|
-
"jupyter": {
|
|
853
|
-
files: [],
|
|
854
|
-
dependencies: ["jupyter"],
|
|
855
|
-
indicators: [".ipynb", "jupyter"]
|
|
856
|
-
},
|
|
857
|
-
"streamlit": {
|
|
858
|
-
files: [],
|
|
859
|
-
dependencies: ["streamlit"],
|
|
860
|
-
indicators: ["streamlit"]
|
|
861
|
-
},
|
|
862
|
-
"dash": {
|
|
863
|
-
files: [],
|
|
864
|
-
dependencies: ["dash"],
|
|
865
|
-
indicators: ["dash"]
|
|
866
|
-
},
|
|
867
|
-
"gradio": {
|
|
868
|
-
files: [],
|
|
869
|
-
dependencies: ["gradio"],
|
|
870
|
-
indicators: ["gradio"]
|
|
871
|
-
},
|
|
872
|
-
"pytest": {
|
|
873
|
-
files: [],
|
|
874
|
-
dependencies: ["pytest"],
|
|
875
|
-
indicators: ["pytest", "conftest.py", "test_"]
|
|
876
|
-
},
|
|
877
|
-
"unittest": {
|
|
878
|
-
files: [],
|
|
879
|
-
dependencies: [],
|
|
880
|
-
indicators: ["test_", "_test.py"]
|
|
881
|
-
},
|
|
882
|
-
"poetry": {
|
|
883
|
-
files: ["pyproject.toml"],
|
|
884
|
-
dependencies: [],
|
|
885
|
-
indicators: ["pyproject.toml", "poetry.lock"]
|
|
886
|
-
},
|
|
887
|
-
"pipenv": {
|
|
888
|
-
files: ["Pipfile"],
|
|
889
|
-
dependencies: [],
|
|
890
|
-
indicators: ["Pipfile", "Pipfile.lock"]
|
|
891
|
-
},
|
|
892
|
-
"conda": {
|
|
893
|
-
files: ["environment.yml", "environment.yaml"],
|
|
894
|
-
dependencies: [],
|
|
895
|
-
indicators: ["environment.yml", "environment.yaml"]
|
|
896
|
-
}
|
|
897
|
-
};
|
|
898
|
-
async function analyzePythonProject(projectPath, files, _languages) {
|
|
899
|
-
logger$4.info("Analyzing Python project");
|
|
900
|
-
const frameworks = [];
|
|
901
|
-
const dependencies = await analyzeDependencies(projectPath, files);
|
|
902
|
-
for (const [frameworkName, patterns] of Object.entries(FRAMEWORK_PATTERNS$2)) {
|
|
903
|
-
const evidence = [];
|
|
904
|
-
let confidence = 0;
|
|
905
|
-
for (const file of patterns.files) {
|
|
906
|
-
if (files.includes(file) || files.some((f) => f.includes(file))) {
|
|
907
|
-
evidence.push(`Found ${file}`);
|
|
908
|
-
confidence += 0.3;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
for (const indicator of patterns.indicators) {
|
|
912
|
-
if (files.some((f) => f.includes(indicator))) {
|
|
913
|
-
evidence.push(`Found ${indicator} pattern`);
|
|
914
|
-
confidence += 0.2;
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
for (const dep of patterns.dependencies) {
|
|
918
|
-
if (dependencies[dep]) {
|
|
919
|
-
evidence.push(`Found ${dep} in dependencies`);
|
|
920
|
-
confidence += 0.4;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
if (confidence > 0) {
|
|
924
|
-
frameworks.push({
|
|
925
|
-
name: frameworkName,
|
|
926
|
-
category: getFrameworkCategory$2(frameworkName),
|
|
927
|
-
version: dependencies[frameworkName],
|
|
928
|
-
confidence: Math.min(confidence, 1),
|
|
929
|
-
evidence
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
await detectAdditionalPatterns$2(projectPath, files, frameworks, dependencies);
|
|
934
|
-
frameworks.sort((a, b) => b.confidence - a.confidence);
|
|
935
|
-
logger$4.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
|
|
936
|
-
return frameworks;
|
|
937
|
-
}
|
|
938
|
-
async function analyzeDependencies(projectPath, files) {
|
|
939
|
-
const dependencies = {};
|
|
940
|
-
const requirementsPath = posix.join(projectPath, "requirements.txt");
|
|
941
|
-
if (files.includes("requirements.txt") && await pathExists$3(requirementsPath)) {
|
|
942
|
-
try {
|
|
943
|
-
const content = await promises.readFile(requirementsPath, "utf-8");
|
|
944
|
-
const lines = content.split("\n");
|
|
945
|
-
for (const line of lines) {
|
|
946
|
-
const trimmed = line.trim();
|
|
947
|
-
if (trimmed && !trimmed.startsWith("#")) {
|
|
948
|
-
const match = trimmed.match(/^([\w-]+)([[~=><].*)?$/);
|
|
949
|
-
if (match) {
|
|
950
|
-
dependencies[match[1]] = match[2] || "latest";
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
} catch (error) {
|
|
955
|
-
logger$4.warn("Failed to parse requirements.txt:", error);
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
const pyprojectPath = posix.join(projectPath, "pyproject.toml");
|
|
959
|
-
if (files.includes("pyproject.toml") && await pathExists$3(pyprojectPath)) {
|
|
960
|
-
try {
|
|
961
|
-
const content = await promises.readFile(pyprojectPath, "utf-8");
|
|
962
|
-
const parsed = parse(content);
|
|
963
|
-
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && "tool" in parsed) {
|
|
964
|
-
const tool = parsed.tool;
|
|
965
|
-
if (typeof tool === "object" && tool !== null && !Array.isArray(tool) && "poetry" in tool) {
|
|
966
|
-
const poetry = tool.poetry;
|
|
967
|
-
if (typeof poetry === "object" && poetry !== null && !Array.isArray(poetry) && "dependencies" in poetry) {
|
|
968
|
-
const poetryDeps = poetry.dependencies;
|
|
969
|
-
if (typeof poetryDeps === "object" && poetryDeps !== null && !Array.isArray(poetryDeps)) {
|
|
970
|
-
Object.assign(dependencies, poetryDeps);
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && "project" in parsed) {
|
|
976
|
-
const project = parsed.project;
|
|
977
|
-
if (typeof project === "object" && project !== null && !Array.isArray(project) && "dependencies" in project) {
|
|
978
|
-
const projectDeps = project.dependencies;
|
|
979
|
-
if (Array.isArray(projectDeps)) {
|
|
980
|
-
for (const dep of projectDeps) {
|
|
981
|
-
if (typeof dep === "string") {
|
|
982
|
-
const match = dep.match(/^([\w-]+)([[~=><].*)?$/);
|
|
983
|
-
if (match) {
|
|
984
|
-
dependencies[match[1]] = match[2] || "latest";
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
} catch (error) {
|
|
992
|
-
logger$4.warn("Failed to parse pyproject.toml:", error);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
const pipfilePath = posix.join(projectPath, "Pipfile");
|
|
996
|
-
if (files.includes("Pipfile") && await pathExists$3(pipfilePath)) {
|
|
997
|
-
try {
|
|
998
|
-
const content = await promises.readFile(pipfilePath, "utf-8");
|
|
999
|
-
const lines = content.split("\n");
|
|
1000
|
-
let inPackages = false;
|
|
1001
|
-
for (const line of lines) {
|
|
1002
|
-
const trimmed = line.trim();
|
|
1003
|
-
if (trimmed === "[packages]") {
|
|
1004
|
-
inPackages = true;
|
|
1005
|
-
continue;
|
|
1006
|
-
}
|
|
1007
|
-
if (trimmed.startsWith("[") && trimmed !== "[packages]") {
|
|
1008
|
-
inPackages = false;
|
|
1009
|
-
continue;
|
|
1010
|
-
}
|
|
1011
|
-
if (inPackages && trimmed && !trimmed.startsWith("#")) {
|
|
1012
|
-
const match = trimmed.match(/^([\w-]+)\s*=\s*"?([^"]*)"?/);
|
|
1013
|
-
if (match) {
|
|
1014
|
-
dependencies[match[1]] = match[2] || "latest";
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
} catch (error) {
|
|
1019
|
-
logger$4.warn("Failed to parse Pipfile:", error);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
const setupPath = posix.join(projectPath, "setup.py");
|
|
1023
|
-
if (files.includes("setup.py") && await pathExists$3(setupPath)) {
|
|
1024
|
-
try {
|
|
1025
|
-
const content = await promises.readFile(setupPath, "utf-8");
|
|
1026
|
-
const installRequiresMatch = content.match(/install_requires\s*=\s*\[([\s\S]*?)\]/);
|
|
1027
|
-
if (installRequiresMatch) {
|
|
1028
|
-
const requiresList = installRequiresMatch[1];
|
|
1029
|
-
const requires = requiresList.match(/['"`]([\w-]+)/g);
|
|
1030
|
-
if (requires) {
|
|
1031
|
-
for (const req of requires) {
|
|
1032
|
-
const name = req.replace(/['"`]/g, "");
|
|
1033
|
-
dependencies[name] = "latest";
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
} catch (error) {
|
|
1038
|
-
logger$4.warn("Failed to parse setup.py:", error);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
const envPath = posix.join(projectPath, "environment.yml");
|
|
1042
|
-
if (files.includes("environment.yml") && await pathExists$3(envPath)) {
|
|
1043
|
-
try {
|
|
1044
|
-
const content = await promises.readFile(envPath, "utf-8");
|
|
1045
|
-
const parsed = parse(content);
|
|
1046
|
-
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) && "dependencies" in parsed) {
|
|
1047
|
-
const deps = parsed.dependencies;
|
|
1048
|
-
if (Array.isArray(deps)) {
|
|
1049
|
-
for (const dep of deps) {
|
|
1050
|
-
if (typeof dep === "string") {
|
|
1051
|
-
const match = dep.match(/^([\w-]+)([[~=><].*)?$/);
|
|
1052
|
-
if (match) {
|
|
1053
|
-
dependencies[match[1]] = match[2] || "latest";
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
} catch (error) {
|
|
1060
|
-
logger$4.warn("Failed to parse environment.yml:", error);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
return dependencies;
|
|
1064
|
-
}
|
|
1065
|
-
function getFrameworkCategory$2(framework) {
|
|
1066
|
-
const categories = {
|
|
1067
|
-
web: [
|
|
1068
|
-
"django",
|
|
1069
|
-
"fastapi",
|
|
1070
|
-
"flask",
|
|
1071
|
-
"tornado",
|
|
1072
|
-
"sanic",
|
|
1073
|
-
"quart",
|
|
1074
|
-
"falcon",
|
|
1075
|
-
"bottle",
|
|
1076
|
-
"pyramid",
|
|
1077
|
-
"starlette"
|
|
1078
|
-
],
|
|
1079
|
-
async: ["celery"],
|
|
1080
|
-
data: ["pandas", "numpy", "scikit-learn", "tensorflow", "pytorch"],
|
|
1081
|
-
notebook: ["jupyter"],
|
|
1082
|
-
ui: ["streamlit", "dash", "gradio"],
|
|
1083
|
-
testing: ["pytest", "unittest"],
|
|
1084
|
-
package: ["poetry", "pipenv", "conda"]
|
|
1085
|
-
};
|
|
1086
|
-
for (const [category, frameworks] of Object.entries(categories)) {
|
|
1087
|
-
if (frameworks.includes(framework)) {
|
|
1088
|
-
return category;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
return "other";
|
|
1092
|
-
}
|
|
1093
|
-
async function detectAdditionalPatterns$2(projectPath, files, frameworks, dependencies) {
|
|
1094
|
-
const pythonVersionPath = posix.join(projectPath, ".python-version");
|
|
1095
|
-
if (files.includes(".python-version") && await pathExists$3(pythonVersionPath)) {
|
|
1096
|
-
try {
|
|
1097
|
-
const version = await promises.readFile(pythonVersionPath, "utf-8");
|
|
1098
|
-
frameworks.push({
|
|
1099
|
-
name: "python",
|
|
1100
|
-
category: "language",
|
|
1101
|
-
version: version.trim(),
|
|
1102
|
-
confidence: 0.9,
|
|
1103
|
-
evidence: ["Found .python-version"]
|
|
1104
|
-
});
|
|
1105
|
-
} catch (error) {
|
|
1106
|
-
logger$4.warn("Failed to read .python-version:", error);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
const dockerFiles = ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"];
|
|
1110
|
-
for (const file of dockerFiles) {
|
|
1111
|
-
if (files.includes(file)) {
|
|
1112
|
-
frameworks.push({
|
|
1113
|
-
name: "docker",
|
|
1114
|
-
category: "deployment",
|
|
1115
|
-
confidence: 0.9,
|
|
1116
|
-
evidence: [`Found ${file}`]
|
|
1117
|
-
});
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
if (files.some((f) => f.startsWith("test_") || f.includes("_test.py"))) {
|
|
1121
|
-
frameworks.push({
|
|
1122
|
-
name: "unittest",
|
|
1123
|
-
category: "testing",
|
|
1124
|
-
confidence: 0.6,
|
|
1125
|
-
evidence: ["Found test files"]
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
const lintingTools = ["flake8", "pylint", "black", "isort", "mypy"];
|
|
1129
|
-
for (const tool of lintingTools) {
|
|
1130
|
-
if (dependencies[tool]) {
|
|
1131
|
-
frameworks.push({
|
|
1132
|
-
name: tool,
|
|
1133
|
-
category: "linting",
|
|
1134
|
-
version: dependencies[tool],
|
|
1135
|
-
confidence: 0.8,
|
|
1136
|
-
evidence: [`Found ${tool} in dependencies`]
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
const configFiles = {
|
|
1141
|
-
"setup.cfg": "setuptools",
|
|
1142
|
-
"tox.ini": "tox",
|
|
1143
|
-
"mypy.ini": "mypy",
|
|
1144
|
-
".flake8": "flake8",
|
|
1145
|
-
".pylintrc": "pylint",
|
|
1146
|
-
"pytest.ini": "pytest",
|
|
1147
|
-
"pyproject.toml": "modern-python"
|
|
1148
|
-
};
|
|
1149
|
-
for (const [file, tool] of Object.entries(configFiles)) {
|
|
1150
|
-
if (files.includes(file)) {
|
|
1151
|
-
frameworks.push({
|
|
1152
|
-
name: tool,
|
|
1153
|
-
category: "config",
|
|
1154
|
-
confidence: 0.8,
|
|
1155
|
-
evidence: [`Found ${file}`]
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
async function pathExists$2(p) {
|
|
1162
|
-
try {
|
|
1163
|
-
await promises.access(p);
|
|
1164
|
-
return true;
|
|
1165
|
-
} catch {
|
|
1166
|
-
return false;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
const logger$3 = consola.withTag("rust-analyzer");
|
|
1170
|
-
const FRAMEWORK_PATTERNS$1 = {
|
|
1171
|
-
"actix-web": {
|
|
1172
|
-
dependencies: ["actix-web"],
|
|
1173
|
-
indicators: ["HttpServer", "web::"]
|
|
1174
|
-
},
|
|
1175
|
-
"rocket": {
|
|
1176
|
-
dependencies: ["rocket"],
|
|
1177
|
-
indicators: ["rocket::", "#[get]", "#[post]"]
|
|
1178
|
-
},
|
|
1179
|
-
"tokio": {
|
|
1180
|
-
dependencies: ["tokio"],
|
|
1181
|
-
indicators: ["tokio::", "#[tokio::main]"]
|
|
1182
|
-
},
|
|
1183
|
-
"async-std": {
|
|
1184
|
-
dependencies: ["async-std"],
|
|
1185
|
-
indicators: ["async_std::"]
|
|
1186
|
-
},
|
|
1187
|
-
"serde": {
|
|
1188
|
-
dependencies: ["serde"],
|
|
1189
|
-
indicators: ["serde::", "Serialize", "Deserialize"]
|
|
1190
|
-
},
|
|
1191
|
-
"clap": {
|
|
1192
|
-
dependencies: ["clap"],
|
|
1193
|
-
indicators: ["clap::", "Command", "Parser"]
|
|
1194
|
-
},
|
|
1195
|
-
"axum": {
|
|
1196
|
-
dependencies: ["axum"],
|
|
1197
|
-
indicators: ["axum::", "Router"]
|
|
1198
|
-
},
|
|
1199
|
-
"warp": {
|
|
1200
|
-
dependencies: ["warp"],
|
|
1201
|
-
indicators: ["warp::", "Filter"]
|
|
1202
|
-
},
|
|
1203
|
-
"hyper": {
|
|
1204
|
-
dependencies: ["hyper"],
|
|
1205
|
-
indicators: ["hyper::", "Request", "Response"]
|
|
1206
|
-
},
|
|
1207
|
-
"tide": {
|
|
1208
|
-
dependencies: ["tide"],
|
|
1209
|
-
indicators: ["tide::", "Server"]
|
|
1210
|
-
},
|
|
1211
|
-
"tracing": {
|
|
1212
|
-
dependencies: ["tracing"],
|
|
1213
|
-
indicators: ["tracing::", "#[instrument]"]
|
|
1214
|
-
},
|
|
1215
|
-
"log": {
|
|
1216
|
-
dependencies: ["log"],
|
|
1217
|
-
indicators: ["log::", "info!", "debug!"]
|
|
1218
|
-
},
|
|
1219
|
-
"anyhow": {
|
|
1220
|
-
dependencies: ["anyhow"],
|
|
1221
|
-
indicators: ["anyhow::", "anyhow!"]
|
|
1222
|
-
},
|
|
1223
|
-
"thiserror": {
|
|
1224
|
-
dependencies: ["thiserror"],
|
|
1225
|
-
indicators: ["thiserror::", "#[error]"]
|
|
1226
|
-
},
|
|
1227
|
-
"sqlx": {
|
|
1228
|
-
dependencies: ["sqlx"],
|
|
1229
|
-
indicators: ["sqlx::", "PgPool"]
|
|
1230
|
-
},
|
|
1231
|
-
"diesel": {
|
|
1232
|
-
dependencies: ["diesel"],
|
|
1233
|
-
indicators: ["diesel::", "prelude::*"]
|
|
1234
|
-
},
|
|
1235
|
-
"sea-orm": {
|
|
1236
|
-
dependencies: ["sea-orm"],
|
|
1237
|
-
indicators: ["sea_orm::", "Database"]
|
|
1238
|
-
},
|
|
1239
|
-
"redis": {
|
|
1240
|
-
dependencies: ["redis"],
|
|
1241
|
-
indicators: ["redis::", "Connection"]
|
|
1242
|
-
},
|
|
1243
|
-
"tokio-postgres": {
|
|
1244
|
-
dependencies: ["tokio-postgres"],
|
|
1245
|
-
indicators: ["tokio_postgres::", "Client"]
|
|
1246
|
-
},
|
|
1247
|
-
"prometheus": {
|
|
1248
|
-
dependencies: ["prometheus"],
|
|
1249
|
-
indicators: ["prometheus::", "Counter"]
|
|
1250
|
-
},
|
|
1251
|
-
"sentry": {
|
|
1252
|
-
dependencies: ["sentry"],
|
|
1253
|
-
indicators: ["sentry::", "capture_event"]
|
|
1254
|
-
},
|
|
1255
|
-
"uuid": {
|
|
1256
|
-
dependencies: ["uuid"],
|
|
1257
|
-
indicators: ["uuid::", "Uuid"]
|
|
1258
|
-
},
|
|
1259
|
-
"chrono": {
|
|
1260
|
-
dependencies: ["chrono"],
|
|
1261
|
-
indicators: ["chrono::", "DateTime"]
|
|
1262
|
-
},
|
|
1263
|
-
"regex": {
|
|
1264
|
-
dependencies: ["regex"],
|
|
1265
|
-
indicators: ["regex::", "Regex"]
|
|
1266
|
-
},
|
|
1267
|
-
"rand": {
|
|
1268
|
-
dependencies: ["rand"],
|
|
1269
|
-
indicators: ["rand::", "Rng"]
|
|
1270
|
-
},
|
|
1271
|
-
"serde_json": {
|
|
1272
|
-
dependencies: ["serde_json"],
|
|
1273
|
-
indicators: ["serde_json::", "json!"]
|
|
1274
|
-
},
|
|
1275
|
-
"tower": {
|
|
1276
|
-
dependencies: ["tower"],
|
|
1277
|
-
indicators: ["tower::", "Service"]
|
|
1278
|
-
},
|
|
1279
|
-
"prost": {
|
|
1280
|
-
dependencies: ["prost"],
|
|
1281
|
-
indicators: ["prost::", "Message"]
|
|
1282
|
-
},
|
|
1283
|
-
"tonic": {
|
|
1284
|
-
dependencies: ["tonic"],
|
|
1285
|
-
indicators: ["tonic::", "#[tonic::async_trait]"]
|
|
1286
|
-
},
|
|
1287
|
-
"yew": {
|
|
1288
|
-
dependencies: ["yew"],
|
|
1289
|
-
indicators: ["yew::", "html!"]
|
|
1290
|
-
},
|
|
1291
|
-
"leptos": {
|
|
1292
|
-
dependencies: ["leptos"],
|
|
1293
|
-
indicators: ["leptos::", "view!"]
|
|
1294
|
-
},
|
|
1295
|
-
"tauri": {
|
|
1296
|
-
dependencies: ["tauri"],
|
|
1297
|
-
indicators: ["tauri::", "#[tauri::command]"]
|
|
1298
|
-
},
|
|
1299
|
-
"bevy": {
|
|
1300
|
-
dependencies: ["bevy"],
|
|
1301
|
-
indicators: ["bevy::", "App"]
|
|
1302
|
-
},
|
|
1303
|
-
"egui": {
|
|
1304
|
-
dependencies: ["egui"],
|
|
1305
|
-
indicators: ["egui::", "CentralPanel"]
|
|
1306
|
-
}
|
|
1307
|
-
};
|
|
1308
|
-
async function analyzeRustProject(projectPath, files, _languages) {
|
|
1309
|
-
logger$3.info("Analyzing Rust project");
|
|
1310
|
-
const frameworks = [];
|
|
1311
|
-
const cargoTomlPath = posix.join(projectPath, "Cargo.toml");
|
|
1312
|
-
let cargoToml = null;
|
|
1313
|
-
try {
|
|
1314
|
-
if (await pathExists$2(cargoTomlPath)) {
|
|
1315
|
-
const content = await promises.readFile(cargoTomlPath, "utf-8");
|
|
1316
|
-
cargoToml = parse(content);
|
|
1317
|
-
}
|
|
1318
|
-
} catch (error) {
|
|
1319
|
-
logger$3.warn("Failed to read Cargo.toml:", error);
|
|
1320
|
-
}
|
|
1321
|
-
const dependencies = extractCargoDependencies(cargoToml);
|
|
1322
|
-
const patterns = await scanRustPatterns(projectPath, files);
|
|
1323
|
-
for (const [frameworkName, frameworkPatterns] of Object.entries(FRAMEWORK_PATTERNS$1)) {
|
|
1324
|
-
const evidence = [];
|
|
1325
|
-
let confidence = 0;
|
|
1326
|
-
for (const dep of frameworkPatterns.dependencies) {
|
|
1327
|
-
if (dependencies[dep]) {
|
|
1328
|
-
evidence.push(`Found ${dep} in dependencies`);
|
|
1329
|
-
confidence += 0.5;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
for (const indicator of frameworkPatterns.indicators) {
|
|
1333
|
-
if (patterns[indicator]) {
|
|
1334
|
-
evidence.push(`Found pattern: ${indicator}`);
|
|
1335
|
-
confidence += 0.3;
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
if (confidence > 0) {
|
|
1339
|
-
frameworks.push({
|
|
1340
|
-
name: frameworkName,
|
|
1341
|
-
category: getFrameworkCategory$1(frameworkName),
|
|
1342
|
-
version: dependencies[frameworkName],
|
|
1343
|
-
confidence: Math.min(confidence, 1),
|
|
1344
|
-
evidence
|
|
1345
|
-
});
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
await detectAdditionalPatterns$1(projectPath, files, frameworks, dependencies, patterns, cargoToml);
|
|
1349
|
-
frameworks.sort((a, b) => b.confidence - a.confidence);
|
|
1350
|
-
logger$3.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
|
|
1351
|
-
return frameworks;
|
|
1352
|
-
}
|
|
1353
|
-
function extractCargoDependencies(cargoToml) {
|
|
1354
|
-
const dependencies = {};
|
|
1355
|
-
if (!cargoToml) {
|
|
1356
|
-
return dependencies;
|
|
1357
|
-
}
|
|
1358
|
-
const depsSections = [
|
|
1359
|
-
cargoToml.dependencies,
|
|
1360
|
-
cargoToml["dev-dependencies"],
|
|
1361
|
-
cargoToml["build-dependencies"]
|
|
1362
|
-
];
|
|
1363
|
-
for (const section of depsSections) {
|
|
1364
|
-
if (typeof section === "object") {
|
|
1365
|
-
for (const [name, version] of Object.entries(section)) {
|
|
1366
|
-
if (typeof version === "string") {
|
|
1367
|
-
dependencies[name] = version;
|
|
1368
|
-
} else if (typeof version === "object" && version !== null && "version" in version) {
|
|
1369
|
-
dependencies[name] = version.version;
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
if (cargoToml.workspace?.dependencies) {
|
|
1375
|
-
for (const [name, version] of Object.entries(cargoToml.workspace.dependencies)) {
|
|
1376
|
-
if (!dependencies[name]) {
|
|
1377
|
-
if (typeof version === "string") {
|
|
1378
|
-
dependencies[name] = version;
|
|
1379
|
-
} else if (typeof version === "object" && version !== null && "version" in version) {
|
|
1380
|
-
dependencies[name] = version.version;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
return dependencies;
|
|
1386
|
-
}
|
|
1387
|
-
async function scanRustPatterns(projectPath, files) {
|
|
1388
|
-
const patterns = {};
|
|
1389
|
-
const rustFiles = files.filter((f) => f.endsWith(".rs"));
|
|
1390
|
-
for (const file of rustFiles) {
|
|
1391
|
-
try {
|
|
1392
|
-
const content = await promises.readFile(posix.join(projectPath, file), "utf-8");
|
|
1393
|
-
const patternRegex = /(\w+::|@\[|!\w+\()/g;
|
|
1394
|
-
let match;
|
|
1395
|
-
while ((match = patternRegex.exec(content)) !== null) {
|
|
1396
|
-
const pattern = match[1];
|
|
1397
|
-
patterns[pattern] = (patterns[pattern] || 0) + 1;
|
|
1398
|
-
}
|
|
1399
|
-
const macroRegex = /(\w+!)/g;
|
|
1400
|
-
while ((match = macroRegex.exec(content)) !== null) {
|
|
1401
|
-
const macroName = match[1];
|
|
1402
|
-
patterns[macroName] = (patterns[macroName] || 0) + 1;
|
|
1403
|
-
}
|
|
1404
|
-
const traitRegex = /:\s*([\w\s,]+)(?:\s*\{|<)/g;
|
|
1405
|
-
while ((match = traitRegex.exec(content)) !== null) {
|
|
1406
|
-
const traits = match[1].split(",").map((t) => t.trim());
|
|
1407
|
-
for (const trait of traits) {
|
|
1408
|
-
patterns[trait] = (patterns[trait] || 0) + 1;
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
} catch (error) {
|
|
1412
|
-
logger$3.warn(`Failed to read ${file}:`, error);
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
return patterns;
|
|
1416
|
-
}
|
|
1417
|
-
function getFrameworkCategory$1(framework) {
|
|
1418
|
-
const categories = {
|
|
1419
|
-
web: [
|
|
1420
|
-
"actix-web",
|
|
1421
|
-
"rocket",
|
|
1422
|
-
"axum",
|
|
1423
|
-
"warp",
|
|
1424
|
-
"hyper",
|
|
1425
|
-
"tide"
|
|
1426
|
-
],
|
|
1427
|
-
async: ["tokio", "async-std"],
|
|
1428
|
-
serialization: ["serde", "serde_json"],
|
|
1429
|
-
cli: ["clap"],
|
|
1430
|
-
error: ["anyhow", "thiserror"],
|
|
1431
|
-
logging: ["tracing", "log"],
|
|
1432
|
-
database: ["sqlx", "diesel", "sea-orm", "tokio-postgres"],
|
|
1433
|
-
cache: ["redis"],
|
|
1434
|
-
monitoring: ["prometheus", "sentry"],
|
|
1435
|
-
utility: ["uuid", "chrono", "regex", "rand"],
|
|
1436
|
-
middleware: ["tower"],
|
|
1437
|
-
rpc: ["prost", "tonic"],
|
|
1438
|
-
frontend: ["yew", "leptos"],
|
|
1439
|
-
desktop: ["tauri"],
|
|
1440
|
-
game: ["bevy"],
|
|
1441
|
-
gui: ["egui"]
|
|
1442
|
-
};
|
|
1443
|
-
for (const [category, frameworks] of Object.entries(categories)) {
|
|
1444
|
-
if (frameworks.includes(framework)) {
|
|
1445
|
-
return category;
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
return "other";
|
|
1449
|
-
}
|
|
1450
|
-
async function detectAdditionalPatterns$1(projectPath, files, frameworks, dependencies, patterns, cargoToml) {
|
|
1451
|
-
if (cargoToml?.package?.edition) {
|
|
1452
|
-
frameworks.push({
|
|
1453
|
-
name: "rust",
|
|
1454
|
-
category: "language",
|
|
1455
|
-
version: cargoToml.package.edition,
|
|
1456
|
-
confidence: 0.9,
|
|
1457
|
-
evidence: ["Found Cargo.toml"]
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
if (cargoToml?.workspace) {
|
|
1461
|
-
frameworks.push({
|
|
1462
|
-
name: "workspace",
|
|
1463
|
-
category: "workspace",
|
|
1464
|
-
confidence: 0.9,
|
|
1465
|
-
evidence: ["Found workspace in Cargo.toml"]
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
|
-
if (cargoToml?.bin) {
|
|
1469
|
-
frameworks.push({
|
|
1470
|
-
name: "binary",
|
|
1471
|
-
category: "build",
|
|
1472
|
-
confidence: 0.8,
|
|
1473
|
-
evidence: ["Found binary targets"]
|
|
1474
|
-
});
|
|
1475
|
-
}
|
|
1476
|
-
if (cargoToml?.lib) {
|
|
1477
|
-
frameworks.push({
|
|
1478
|
-
name: "library",
|
|
1479
|
-
category: "build",
|
|
1480
|
-
confidence: 0.8,
|
|
1481
|
-
evidence: ["Found library configuration"]
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
const dockerFiles = ["Dockerfile", "docker-compose.yml", "docker-compose.yaml"];
|
|
1485
|
-
for (const file of dockerFiles) {
|
|
1486
|
-
if (files.includes(file)) {
|
|
1487
|
-
frameworks.push({
|
|
1488
|
-
name: "docker",
|
|
1489
|
-
category: "deployment",
|
|
1490
|
-
confidence: 0.9,
|
|
1491
|
-
evidence: [`Found ${file}`]
|
|
1492
|
-
});
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
if (files.some((f) => f.endsWith("_test.rs")) || patterns["#["] && patterns["#["] > 0) {
|
|
1496
|
-
frameworks.push({
|
|
1497
|
-
name: "testing",
|
|
1498
|
-
category: "testing",
|
|
1499
|
-
confidence: 0.7,
|
|
1500
|
-
evidence: ["Found test files"]
|
|
1501
|
-
});
|
|
1502
|
-
}
|
|
1503
|
-
if (files.some((f) => f.endsWith("_bench.rs"))) {
|
|
1504
|
-
frameworks.push({
|
|
1505
|
-
name: "benchmark",
|
|
1506
|
-
category: "testing",
|
|
1507
|
-
confidence: 0.8,
|
|
1508
|
-
evidence: ["Found benchmark files"]
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
if (files.some((f) => f.startsWith("examples/"))) {
|
|
1512
|
-
frameworks.push({
|
|
1513
|
-
name: "examples",
|
|
1514
|
-
category: "documentation",
|
|
1515
|
-
confidence: 0.7,
|
|
1516
|
-
evidence: ["Found examples directory"]
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
const ciFiles = {
|
|
1520
|
-
".github/workflows": "github-actions",
|
|
1521
|
-
".gitlab-ci.yml": "gitlab-ci",
|
|
1522
|
-
"Jenkinsfile": "jenkins",
|
|
1523
|
-
".travis.yml": "travis-ci"
|
|
1524
|
-
};
|
|
1525
|
-
for (const [file, tool] of Object.entries(ciFiles)) {
|
|
1526
|
-
if (files.includes(file) || files.some((f) => f.startsWith(file))) {
|
|
1527
|
-
frameworks.push({
|
|
1528
|
-
name: tool,
|
|
1529
|
-
category: "ci-cd",
|
|
1530
|
-
confidence: 0.8,
|
|
1531
|
-
evidence: [`Found ${file}`]
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
const buildFiles = {
|
|
1536
|
-
"Makefile": "make",
|
|
1537
|
-
"justfile": "just",
|
|
1538
|
-
"build.rs": "build-script"
|
|
1539
|
-
};
|
|
1540
|
-
for (const [file, tool] of Object.entries(buildFiles)) {
|
|
1541
|
-
if (files.includes(file)) {
|
|
1542
|
-
frameworks.push({
|
|
1543
|
-
name: tool,
|
|
1544
|
-
category: "build",
|
|
1545
|
-
confidence: 0.8,
|
|
1546
|
-
evidence: [`Found ${file}`]
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
if (files.some((f) => f.endsWith(".proto"))) {
|
|
1551
|
-
frameworks.push({
|
|
1552
|
-
name: "protobuf",
|
|
1553
|
-
category: "rpc",
|
|
1554
|
-
confidence: 0.9,
|
|
1555
|
-
evidence: ["Found .proto files"]
|
|
1556
|
-
});
|
|
1557
|
-
}
|
|
1558
|
-
if (dependencies["wasm-bindgen"] || dependencies["wasm-pack"]) {
|
|
1559
|
-
frameworks.push({
|
|
1560
|
-
name: "wasm",
|
|
1561
|
-
category: "webassembly",
|
|
1562
|
-
confidence: 0.8,
|
|
1563
|
-
evidence: ["Found WASM dependencies"]
|
|
1564
|
-
});
|
|
1565
|
-
}
|
|
1566
|
-
if (patterns["#![no_std]"]) {
|
|
1567
|
-
frameworks.push({
|
|
1568
|
-
name: "no_std",
|
|
1569
|
-
category: "embedded",
|
|
1570
|
-
confidence: 0.9,
|
|
1571
|
-
evidence: ["Found #![no_std]"]
|
|
1572
|
-
});
|
|
1573
|
-
}
|
|
1574
|
-
if (cargoToml?.lib?.proc_macro) {
|
|
1575
|
-
frameworks.push({
|
|
1576
|
-
name: "proc-macro",
|
|
1577
|
-
category: "meta",
|
|
1578
|
-
confidence: 0.9,
|
|
1579
|
-
evidence: ["Found proc-macro configuration"]
|
|
1580
|
-
});
|
|
1581
|
-
}
|
|
1582
|
-
if (dependencies.clippy) {
|
|
1583
|
-
frameworks.push({
|
|
1584
|
-
name: "clippy",
|
|
1585
|
-
category: "linting",
|
|
1586
|
-
confidence: 0.8,
|
|
1587
|
-
evidence: ["Found clippy dependency"]
|
|
1588
|
-
});
|
|
1589
|
-
}
|
|
1590
|
-
if (dependencies.rustfmt) {
|
|
1591
|
-
frameworks.push({
|
|
1592
|
-
name: "rustfmt",
|
|
1593
|
-
category: "formatting",
|
|
1594
|
-
confidence: 0.8,
|
|
1595
|
-
evidence: ["Found rustfmt dependency"]
|
|
1596
|
-
});
|
|
1597
|
-
}
|
|
1598
|
-
if (dependencies.rustdoc) {
|
|
1599
|
-
frameworks.push({
|
|
1600
|
-
name: "rustdoc",
|
|
1601
|
-
category: "documentation",
|
|
1602
|
-
confidence: 0.8,
|
|
1603
|
-
evidence: ["Found rustdoc dependency"]
|
|
1604
|
-
});
|
|
1605
|
-
}
|
|
1606
|
-
if (cargoToml?.package?.publish) {
|
|
1607
|
-
frameworks.push({
|
|
1608
|
-
name: "crates.io",
|
|
1609
|
-
category: "registry",
|
|
1610
|
-
confidence: 0.7,
|
|
1611
|
-
evidence: ["Found publish configuration"]
|
|
1612
|
-
});
|
|
1613
|
-
}
|
|
1614
|
-
if (cargoToml?.package?.license) {
|
|
1615
|
-
frameworks.push({
|
|
1616
|
-
name: cargoToml.package.license,
|
|
1617
|
-
category: "legal",
|
|
1618
|
-
confidence: 0.6,
|
|
1619
|
-
evidence: ["Found license in Cargo.toml"]
|
|
1620
|
-
});
|
|
1621
|
-
}
|
|
1622
|
-
if (cargoToml?.package) {
|
|
1623
|
-
const type = cargoToml.bin ? "binary" : cargoToml.lib ? "library" : "unknown";
|
|
1624
|
-
frameworks.push({
|
|
1625
|
-
name: type,
|
|
1626
|
-
category: "package",
|
|
1627
|
-
confidence: 0.9,
|
|
1628
|
-
evidence: [`Detected as ${type}`]
|
|
1629
|
-
});
|
|
1630
|
-
}
|
|
1631
|
-
if (files.includes("target/") || files.some((f) => f.startsWith("target/"))) {
|
|
1632
|
-
logger$3.debug("Found target/ directory (build artifacts)");
|
|
1633
|
-
}
|
|
1634
|
-
if (files.includes("Cargo.lock")) {
|
|
1635
|
-
frameworks.push({
|
|
1636
|
-
name: "cargo-lock",
|
|
1637
|
-
category: "dependency",
|
|
1638
|
-
confidence: 0.9,
|
|
1639
|
-
evidence: ["Found Cargo.lock"]
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
async function pathExists$1(p) {
|
|
1645
|
-
try {
|
|
1646
|
-
await promises.access(p);
|
|
1647
|
-
return true;
|
|
1648
|
-
} catch {
|
|
1649
|
-
return false;
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
async function readJson(p) {
|
|
1653
|
-
const content = await promises.readFile(p, "utf-8");
|
|
1654
|
-
return JSON.parse(content);
|
|
1655
|
-
}
|
|
1656
|
-
const logger$2 = consola.withTag("typescript-analyzer");
|
|
1657
|
-
const FRAMEWORK_PATTERNS = {
|
|
1658
|
-
"next.js": {
|
|
1659
|
-
files: ["next.config.js", "next.config.ts", "next.config.mjs"],
|
|
1660
|
-
dependencies: ["next"],
|
|
1661
|
-
indicators: ["pages/", "app/", "src/app/", "src/pages/"]
|
|
1662
|
-
},
|
|
1663
|
-
"nuxt": {
|
|
1664
|
-
files: ["nuxt.config.js", "nuxt.config.ts"],
|
|
1665
|
-
dependencies: ["nuxt"],
|
|
1666
|
-
indicators: ["pages/", "layouts/", "components/", "store/"]
|
|
1667
|
-
},
|
|
1668
|
-
"sveltekit": {
|
|
1669
|
-
files: ["svelte.config.js", "svelte.config.ts"],
|
|
1670
|
-
dependencies: ["@sveltejs/kit"],
|
|
1671
|
-
indicators: ["src/routes/", "src/lib/", ".svelte-kit/"]
|
|
1672
|
-
},
|
|
1673
|
-
"astro": {
|
|
1674
|
-
files: ["astro.config.js", "astro.config.mjs", "astro.config.ts"],
|
|
1675
|
-
dependencies: ["astro"],
|
|
1676
|
-
indicators: ["src/pages/", "src/content/", "src/components/"]
|
|
1677
|
-
},
|
|
1678
|
-
"solidstart": {
|
|
1679
|
-
files: ["vite.config.ts", "vite.config.js"],
|
|
1680
|
-
dependencies: ["solid-start"],
|
|
1681
|
-
indicators: ["src/routes/", "src/components/"]
|
|
1682
|
-
},
|
|
1683
|
-
"qwik": {
|
|
1684
|
-
files: ["vite.config.ts"],
|
|
1685
|
-
dependencies: ["@builder.io/qwik"],
|
|
1686
|
-
indicators: ["src/routes/", "src/components/"]
|
|
1687
|
-
},
|
|
1688
|
-
"remix": {
|
|
1689
|
-
files: ["remix.config.js", "vite.config.ts"],
|
|
1690
|
-
dependencies: ["@remix-run/node"],
|
|
1691
|
-
indicators: ["app/", "app/routes/", "app/components/"]
|
|
1692
|
-
},
|
|
1693
|
-
"gatsby": {
|
|
1694
|
-
files: ["gatsby-config.js", "gatsby-config.ts"],
|
|
1695
|
-
dependencies: ["gatsby"],
|
|
1696
|
-
indicators: ["src/pages/", "src/templates/", "gatsby-node.js"]
|
|
1697
|
-
},
|
|
1698
|
-
"vue": {
|
|
1699
|
-
files: ["vue.config.js"],
|
|
1700
|
-
dependencies: ["vue"],
|
|
1701
|
-
indicators: ["src/components/", "src/views/", "src/router/"]
|
|
1702
|
-
},
|
|
1703
|
-
"angular": {
|
|
1704
|
-
files: ["angular.json"],
|
|
1705
|
-
dependencies: ["@angular/core"],
|
|
1706
|
-
indicators: ["src/app/", "e2e/", ".angular/"]
|
|
1707
|
-
},
|
|
1708
|
-
"react": {
|
|
1709
|
-
files: [],
|
|
1710
|
-
dependencies: ["react", "react-dom"],
|
|
1711
|
-
indicators: ["src/", "components/", "src/components/"]
|
|
1712
|
-
},
|
|
1713
|
-
"preact": {
|
|
1714
|
-
files: [],
|
|
1715
|
-
dependencies: ["preact"],
|
|
1716
|
-
indicators: ["src/", "components/"]
|
|
1717
|
-
},
|
|
1718
|
-
"solidjs": {
|
|
1719
|
-
files: [],
|
|
1720
|
-
dependencies: ["solid-js"],
|
|
1721
|
-
indicators: ["src/", "components/"]
|
|
1722
|
-
},
|
|
1723
|
-
"svelte": {
|
|
1724
|
-
files: [],
|
|
1725
|
-
dependencies: ["svelte"],
|
|
1726
|
-
indicators: ["src/", "components/", "src/components/"]
|
|
1727
|
-
},
|
|
1728
|
-
"nest.js": {
|
|
1729
|
-
files: ["nest-cli.json"],
|
|
1730
|
-
dependencies: ["@nestjs/core"],
|
|
1731
|
-
indicators: ["src/", "src/modules/", "src/controllers/"]
|
|
1732
|
-
},
|
|
1733
|
-
"express": {
|
|
1734
|
-
files: [],
|
|
1735
|
-
dependencies: ["express"],
|
|
1736
|
-
indicators: ["app.js", "server.js", "routes/", "middleware/"]
|
|
1737
|
-
},
|
|
1738
|
-
"fastify": {
|
|
1739
|
-
files: [],
|
|
1740
|
-
dependencies: ["fastify"],
|
|
1741
|
-
indicators: ["app.js", "server.js", "routes/", "plugins/"]
|
|
1742
|
-
},
|
|
1743
|
-
"koa": {
|
|
1744
|
-
files: [],
|
|
1745
|
-
dependencies: ["koa"],
|
|
1746
|
-
indicators: ["app.js", "server.js", "middleware/"]
|
|
1747
|
-
},
|
|
1748
|
-
"adonisjs": {
|
|
1749
|
-
files: [".adonisrc.json"],
|
|
1750
|
-
dependencies: ["@adonisjs/core"],
|
|
1751
|
-
indicators: ["app/", "config/", "start/", "providers/"]
|
|
1752
|
-
},
|
|
1753
|
-
"feathers": {
|
|
1754
|
-
files: [],
|
|
1755
|
-
dependencies: ["@feathersjs/feathers"],
|
|
1756
|
-
indicators: ["src/", "services/"]
|
|
1757
|
-
},
|
|
1758
|
-
"meteor": {
|
|
1759
|
-
files: [".meteor/"],
|
|
1760
|
-
dependencies: ["meteor-node-stubs"],
|
|
1761
|
-
indicators: ["client/", "server/", "imports/"]
|
|
1762
|
-
},
|
|
1763
|
-
"ionic": {
|
|
1764
|
-
files: ["ionic.config.json"],
|
|
1765
|
-
dependencies: ["@ionic/core"],
|
|
1766
|
-
indicators: ["src/", "www/"]
|
|
1767
|
-
},
|
|
1768
|
-
"electron": {
|
|
1769
|
-
files: [],
|
|
1770
|
-
dependencies: ["electron"],
|
|
1771
|
-
indicators: ["main.js", "src/main/", "electron/"]
|
|
1772
|
-
},
|
|
1773
|
-
"turborepo": {
|
|
1774
|
-
files: ["turbo.json"],
|
|
1775
|
-
dependencies: ["turbo"],
|
|
1776
|
-
indicators: ["apps/", "packages/"]
|
|
1777
|
-
},
|
|
1778
|
-
"nx": {
|
|
1779
|
-
files: ["nx.json"],
|
|
1780
|
-
dependencies: ["nx"],
|
|
1781
|
-
indicators: ["apps/", "libs/"]
|
|
1782
|
-
},
|
|
1783
|
-
"lerna": {
|
|
1784
|
-
files: ["lerna.json"],
|
|
1785
|
-
dependencies: ["lerna"],
|
|
1786
|
-
indicators: ["packages/"]
|
|
1787
|
-
}
|
|
1788
|
-
};
|
|
1789
|
-
async function analyzeTypeScriptProject(projectPath, files, _languages) {
|
|
1790
|
-
logger$2.info("Analyzing TypeScript/JavaScript project");
|
|
1791
|
-
const frameworks = [];
|
|
1792
|
-
const packageJsonPath = posix.join(projectPath, "package.json");
|
|
1793
|
-
let packageJson = null;
|
|
1794
|
-
try {
|
|
1795
|
-
if (await pathExists$1(packageJsonPath)) {
|
|
1796
|
-
packageJson = await readJson(packageJsonPath);
|
|
1797
|
-
}
|
|
1798
|
-
} catch (error) {
|
|
1799
|
-
logger$2.warn("Failed to read package.json:", error);
|
|
1800
|
-
}
|
|
1801
|
-
for (const [frameworkName, patterns] of Object.entries(FRAMEWORK_PATTERNS)) {
|
|
1802
|
-
const evidence = [];
|
|
1803
|
-
let confidence = 0;
|
|
1804
|
-
for (const file of patterns.files) {
|
|
1805
|
-
if (files.includes(file)) {
|
|
1806
|
-
evidence.push(`Found ${file}`);
|
|
1807
|
-
confidence += 0.3;
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
for (const indicator of patterns.indicators) {
|
|
1811
|
-
const indicatorPath = posix.join(projectPath, indicator);
|
|
1812
|
-
if (files.some((f) => f.startsWith(indicator)) || await pathExists$1(indicatorPath)) {
|
|
1813
|
-
evidence.push(`Found ${indicator} directory`);
|
|
1814
|
-
confidence += 0.2;
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
if (packageJson) {
|
|
1818
|
-
const allDeps = {
|
|
1819
|
-
...packageJson.dependencies,
|
|
1820
|
-
...packageJson.devDependencies
|
|
1821
|
-
};
|
|
1822
|
-
for (const dep of patterns.dependencies) {
|
|
1823
|
-
if (allDeps[dep]) {
|
|
1824
|
-
evidence.push(`Found ${dep} in dependencies`);
|
|
1825
|
-
confidence += 0.4;
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
if (confidence > 0) {
|
|
1830
|
-
let version;
|
|
1831
|
-
if (packageJson) {
|
|
1832
|
-
for (const dep of patterns.dependencies) {
|
|
1833
|
-
const depVersion = packageJson.dependencies?.[dep] || packageJson.devDependencies?.[dep];
|
|
1834
|
-
if (depVersion) {
|
|
1835
|
-
version = depVersion;
|
|
1836
|
-
break;
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
frameworks.push({
|
|
1841
|
-
name: frameworkName,
|
|
1842
|
-
category: getFrameworkCategory(frameworkName),
|
|
1843
|
-
version,
|
|
1844
|
-
confidence: Math.min(confidence, 1),
|
|
1845
|
-
evidence
|
|
1846
|
-
});
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
await detectAdditionalPatterns(projectPath, files, frameworks, packageJson);
|
|
1850
|
-
frameworks.sort((a, b) => b.confidence - a.confidence);
|
|
1851
|
-
logger$2.debug(`Detected frameworks: ${frameworks.map((f) => `${f.name} (${Math.round(f.confidence * 100)}%)`).join(", ")}`);
|
|
1852
|
-
return frameworks;
|
|
1853
|
-
}
|
|
1854
|
-
function getFrameworkCategory(framework) {
|
|
1855
|
-
const categories = {
|
|
1856
|
-
frontend: [
|
|
1857
|
-
"next.js",
|
|
1858
|
-
"nuxt",
|
|
1859
|
-
"sveltekit",
|
|
1860
|
-
"astro",
|
|
1861
|
-
"solidstart",
|
|
1862
|
-
"qwik",
|
|
1863
|
-
"remix",
|
|
1864
|
-
"gatsby",
|
|
1865
|
-
"vue",
|
|
1866
|
-
"angular",
|
|
1867
|
-
"react",
|
|
1868
|
-
"preact",
|
|
1869
|
-
"solidjs",
|
|
1870
|
-
"svelte",
|
|
1871
|
-
"ionic"
|
|
1872
|
-
],
|
|
1873
|
-
backend: [
|
|
1874
|
-
"nest.js",
|
|
1875
|
-
"express",
|
|
1876
|
-
"fastify",
|
|
1877
|
-
"koa",
|
|
1878
|
-
"adonisjs",
|
|
1879
|
-
"feathers",
|
|
1880
|
-
"meteor"
|
|
1881
|
-
],
|
|
1882
|
-
desktop: ["electron"],
|
|
1883
|
-
monorepo: ["turborepo", "nx", "lerna"]
|
|
1884
|
-
};
|
|
1885
|
-
for (const [category, frameworks] of Object.entries(categories)) {
|
|
1886
|
-
if (frameworks.includes(framework)) {
|
|
1887
|
-
return category;
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
return "other";
|
|
1891
|
-
}
|
|
1892
|
-
async function detectAdditionalPatterns(projectPath, files, frameworks, packageJson) {
|
|
1893
|
-
if (files.includes("tsconfig.json")) {
|
|
1894
|
-
const tsFramework = frameworks.find((f) => f.name === "typescript");
|
|
1895
|
-
if (!tsFramework) {
|
|
1896
|
-
frameworks.push({
|
|
1897
|
-
name: "typescript",
|
|
1898
|
-
category: "language",
|
|
1899
|
-
confidence: 0.9,
|
|
1900
|
-
evidence: ["Found tsconfig.json"]
|
|
1901
|
-
});
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
const testDependencies = ["jest", "vitest", "cypress", "playwright", "mocha", "jasmine"];
|
|
1905
|
-
if (packageJson) {
|
|
1906
|
-
const allDeps = {
|
|
1907
|
-
...packageJson.dependencies,
|
|
1908
|
-
...packageJson.devDependencies
|
|
1909
|
-
};
|
|
1910
|
-
for (const testDep of testDependencies) {
|
|
1911
|
-
if (allDeps[testDep]) {
|
|
1912
|
-
frameworks.push({
|
|
1913
|
-
name: testDep,
|
|
1914
|
-
category: "testing",
|
|
1915
|
-
version: allDeps[testDep],
|
|
1916
|
-
confidence: 0.8,
|
|
1917
|
-
evidence: [`Found ${testDep} in dependencies`]
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
const cssFrameworks = ["tailwindcss", "bootstrap", "bulma", "material-ui", "chakra-ui"];
|
|
1923
|
-
if (packageJson) {
|
|
1924
|
-
const allDeps = {
|
|
1925
|
-
...packageJson.dependencies,
|
|
1926
|
-
...packageJson.devDependencies
|
|
1927
|
-
};
|
|
1928
|
-
for (const cssFw of cssFrameworks) {
|
|
1929
|
-
if (allDeps[cssFw]) {
|
|
1930
|
-
frameworks.push({
|
|
1931
|
-
name: cssFw,
|
|
1932
|
-
category: "css",
|
|
1933
|
-
version: allDeps[cssFw],
|
|
1934
|
-
confidence: 0.8,
|
|
1935
|
-
evidence: [`Found ${cssFw} in dependencies`]
|
|
1936
|
-
});
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
const stateLibs = ["redux", "zustand", "recoil", "jotai", "valtio"];
|
|
1941
|
-
if (packageJson) {
|
|
1942
|
-
const allDeps = {
|
|
1943
|
-
...packageJson.dependencies,
|
|
1944
|
-
...packageJson.devDependencies
|
|
1945
|
-
};
|
|
1946
|
-
for (const lib of stateLibs) {
|
|
1947
|
-
if (allDeps[lib]) {
|
|
1948
|
-
frameworks.push({
|
|
1949
|
-
name: lib,
|
|
1950
|
-
category: "state-management",
|
|
1951
|
-
version: allDeps[lib],
|
|
1952
|
-
confidence: 0.8,
|
|
1953
|
-
evidence: [`Found ${lib} in dependencies`]
|
|
1954
|
-
});
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
const lintingTools = ["eslint", "prettier", "biome", "rome"];
|
|
1959
|
-
if (packageJson) {
|
|
1960
|
-
const allDeps = {
|
|
1961
|
-
...packageJson.dependencies,
|
|
1962
|
-
...packageJson.devDependencies
|
|
1963
|
-
};
|
|
1964
|
-
for (const tool of lintingTools) {
|
|
1965
|
-
if (allDeps[tool]) {
|
|
1966
|
-
frameworks.push({
|
|
1967
|
-
name: tool,
|
|
1968
|
-
category: "linting",
|
|
1969
|
-
version: allDeps[tool],
|
|
1970
|
-
confidence: 0.8,
|
|
1971
|
-
evidence: [`Found ${tool} in dependencies`]
|
|
1972
|
-
});
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
const deploymentFiles = {
|
|
1977
|
-
"vercel.json": "vercel",
|
|
1978
|
-
"netlify.toml": "netlify",
|
|
1979
|
-
"app.yaml": "app-engine",
|
|
1980
|
-
"now.json": "now"
|
|
1981
|
-
};
|
|
1982
|
-
for (const [file, platform] of Object.entries(deploymentFiles)) {
|
|
1983
|
-
if (files.includes(file)) {
|
|
1984
|
-
frameworks.push({
|
|
1985
|
-
name: platform,
|
|
1986
|
-
category: "deployment",
|
|
1987
|
-
confidence: 0.9,
|
|
1988
|
-
evidence: [`Found ${file}`]
|
|
1989
|
-
});
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
|
|
1994
|
-
async function pathExists(p) {
|
|
1995
|
-
try {
|
|
1996
|
-
await promises.access(p);
|
|
1997
|
-
return true;
|
|
1998
|
-
} catch {
|
|
1999
|
-
return false;
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
const logger$1 = consola.withTag("project-detector");
|
|
2003
|
-
const LANGUAGE_PATTERNS = {
|
|
2004
|
-
typescript: {
|
|
2005
|
-
files: ["package.json", "tsconfig.json", "tsconfig.build.json"],
|
|
2006
|
-
extensions: [".ts", ".tsx", ".mts", ".cts"],
|
|
2007
|
-
indicators: ["node_modules", "yarn.lock", "package-lock.json", "pnpm-lock.yaml"]
|
|
2008
|
-
},
|
|
2009
|
-
javascript: {
|
|
2010
|
-
files: ["package.json"],
|
|
2011
|
-
extensions: [".js", ".jsx", ".mjs", ".cjs"],
|
|
2012
|
-
indicators: ["node_modules", "yarn.lock", "package-lock.json", "pnpm-lock.yaml"]
|
|
2013
|
-
},
|
|
2014
|
-
python: {
|
|
2015
|
-
files: ["requirements.txt", "pyproject.toml", "setup.py", "Pipfile"],
|
|
2016
|
-
extensions: [".py", ".pyx", ".pyi"],
|
|
2017
|
-
indicators: [".venv", "venv", "__pycache__", ".python-version"]
|
|
2018
|
-
},
|
|
2019
|
-
go: {
|
|
2020
|
-
files: ["go.mod", "go.sum"],
|
|
2021
|
-
extensions: [".go"],
|
|
2022
|
-
indicators: ["vendor", "Gopkg.lock"]
|
|
2023
|
-
},
|
|
2024
|
-
rust: {
|
|
2025
|
-
files: ["Cargo.toml", "Cargo.lock"],
|
|
2026
|
-
extensions: [".rs"],
|
|
2027
|
-
indicators: ["target"]
|
|
2028
|
-
},
|
|
2029
|
-
java: {
|
|
2030
|
-
files: ["pom.xml", "build.gradle", "build.gradle.kts"],
|
|
2031
|
-
extensions: [".java", ".kt"],
|
|
2032
|
-
indicators: ["gradlew", "mvnw"]
|
|
2033
|
-
},
|
|
2034
|
-
dotnet: {
|
|
2035
|
-
files: ["*.csproj", "*.sln", "*.fsproj", "*.vbproj"],
|
|
2036
|
-
extensions: [".cs", ".fs", ".vb"],
|
|
2037
|
-
indicators: ["bin", "obj"]
|
|
2038
|
-
},
|
|
2039
|
-
ruby: {
|
|
2040
|
-
files: ["Gemfile", "Gemfile.lock"],
|
|
2041
|
-
extensions: [".rb"],
|
|
2042
|
-
indicators: ["vendor/bundle"]
|
|
2043
|
-
},
|
|
2044
|
-
php: {
|
|
2045
|
-
files: ["composer.json", "composer.lock"],
|
|
2046
|
-
extensions: [".php"],
|
|
2047
|
-
indicators: ["vendor"]
|
|
2048
|
-
},
|
|
2049
|
-
swift: {
|
|
2050
|
-
files: ["Package.swift"],
|
|
2051
|
-
extensions: [".swift"],
|
|
2052
|
-
indicators: [".build"]
|
|
2053
|
-
},
|
|
2054
|
-
kotlin: {
|
|
2055
|
-
files: ["build.gradle.kts"],
|
|
2056
|
-
extensions: [".kt", ".kts"],
|
|
2057
|
-
indicators: ["gradlew"]
|
|
2058
|
-
},
|
|
2059
|
-
dart: {
|
|
2060
|
-
files: ["pubspec.yaml"],
|
|
2061
|
-
extensions: [".dart"],
|
|
2062
|
-
indicators: [".dart_tool"]
|
|
2063
|
-
}
|
|
2064
|
-
};
|
|
2065
|
-
const FRAMEWORK_PRIORITY = {
|
|
2066
|
-
"next.js": 10,
|
|
2067
|
-
"nuxt": 9,
|
|
2068
|
-
"sveltekit": 8,
|
|
2069
|
-
"astro": 7,
|
|
2070
|
-
"solidstart": 6,
|
|
2071
|
-
"qwik": 5,
|
|
2072
|
-
"remix": 4,
|
|
2073
|
-
"gatsby": 3,
|
|
2074
|
-
"create-react-app": 2,
|
|
2075
|
-
"vue": 1,
|
|
2076
|
-
"angular": 1,
|
|
2077
|
-
"react": 0
|
|
2078
|
-
};
|
|
2079
|
-
async function detectProject(projectPath, config) {
|
|
2080
|
-
const startTime = Date.now();
|
|
2081
|
-
logger$1.info(`Detecting project at: ${projectPath}`);
|
|
2082
|
-
const absolutePath = posix.resolve(projectPath);
|
|
2083
|
-
if (!await pathExists(absolutePath)) {
|
|
2084
|
-
throw new Error(`Project path does not exist: ${absolutePath}`);
|
|
2085
|
-
}
|
|
2086
|
-
const files = await scanProjectFiles(absolutePath, config);
|
|
2087
|
-
logger$1.debug(`Scanned ${files.length} files`);
|
|
2088
|
-
const languages = await detectLanguages(absolutePath, files, config);
|
|
2089
|
-
logger$1.debug(`Detected languages: ${languages.map((l) => l.language).join(", ")}`);
|
|
2090
|
-
languages.sort((a, b) => b.confidence - a.confidence);
|
|
2091
|
-
const primaryLanguage = languages[0];
|
|
2092
|
-
let frameworks = [];
|
|
2093
|
-
if (primaryLanguage) {
|
|
2094
|
-
switch (primaryLanguage.language) {
|
|
2095
|
-
case "typescript":
|
|
2096
|
-
case "javascript":
|
|
2097
|
-
frameworks = await analyzeTypeScriptProject(absolutePath, files);
|
|
2098
|
-
break;
|
|
2099
|
-
case "python":
|
|
2100
|
-
frameworks = await analyzePythonProject(absolutePath, files);
|
|
2101
|
-
break;
|
|
2102
|
-
case "go":
|
|
2103
|
-
frameworks = await analyzeGoProject(absolutePath, files);
|
|
2104
|
-
break;
|
|
2105
|
-
case "rust":
|
|
2106
|
-
frameworks = await analyzeRustProject(absolutePath, files);
|
|
2107
|
-
break;
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
const packageManager = detectPackageManager(files);
|
|
2111
|
-
const buildSystem = detectBuildSystem(files, frameworks);
|
|
2112
|
-
const configFiles = detectConfigFiles(files);
|
|
2113
|
-
const importantDirs = detectImportantDirs(absolutePath);
|
|
2114
|
-
const analysis = {
|
|
2115
|
-
rootPath: absolutePath,
|
|
2116
|
-
projectType: determineProjectType(languages, frameworks),
|
|
2117
|
-
languages,
|
|
2118
|
-
frameworks,
|
|
2119
|
-
packageManager,
|
|
2120
|
-
buildSystem,
|
|
2121
|
-
configFiles,
|
|
2122
|
-
importantDirs,
|
|
2123
|
-
metadata: {
|
|
2124
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
2125
|
-
duration: Date.now() - startTime,
|
|
2126
|
-
filesScanned: files.length,
|
|
2127
|
-
confidence: calculateOverallConfidence(languages, frameworks),
|
|
2128
|
-
version: "1.0.0"
|
|
2129
|
-
}
|
|
2130
|
-
};
|
|
2131
|
-
logger$1.info(`Detected project type: ${analysis.projectType}`);
|
|
2132
|
-
return analysis;
|
|
2133
|
-
}
|
|
2134
|
-
const ROOT_CONFIG_FILES = [
|
|
2135
|
-
"package.json",
|
|
2136
|
-
"tsconfig.json",
|
|
2137
|
-
"jsconfig.json",
|
|
2138
|
-
"go.mod",
|
|
2139
|
-
"Cargo.toml",
|
|
2140
|
-
"pyproject.toml",
|
|
2141
|
-
"requirements.txt",
|
|
2142
|
-
"setup.py",
|
|
2143
|
-
"Gemfile",
|
|
2144
|
-
"composer.json",
|
|
2145
|
-
"pom.xml",
|
|
2146
|
-
"build.gradle",
|
|
2147
|
-
"build.gradle.kts",
|
|
2148
|
-
"pubspec.yaml",
|
|
2149
|
-
"Package.swift",
|
|
2150
|
-
"pom.xml"
|
|
2151
|
-
];
|
|
2152
|
-
async function scanProjectFiles(projectPath, config) {
|
|
2153
|
-
const rootConfigFiles = [];
|
|
2154
|
-
for (const configFile of ROOT_CONFIG_FILES) {
|
|
2155
|
-
const configPath = posix.join(projectPath, configFile);
|
|
2156
|
-
if (await pathExists(configPath)) {
|
|
2157
|
-
rootConfigFiles.push(configFile);
|
|
2158
|
-
logger$1.debug(`Found root config: ${configFile}`);
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
const patterns = ["**/*"];
|
|
2162
|
-
const ignore = config.excludePatterns;
|
|
2163
|
-
if (!config.includeNodeModules) {
|
|
2164
|
-
ignore.push("node_modules/**");
|
|
2165
|
-
}
|
|
2166
|
-
const allFiles = await glob(patterns, {
|
|
2167
|
-
cwd: projectPath,
|
|
2168
|
-
ignore,
|
|
2169
|
-
absolute: false
|
|
2170
|
-
});
|
|
2171
|
-
const fileSet = /* @__PURE__ */ new Set([...rootConfigFiles, ...allFiles]);
|
|
2172
|
-
const files = Array.from(fileSet);
|
|
2173
|
-
if (files.length > config.maxFilesToScan) {
|
|
2174
|
-
logger$1.warn(`Too many files (${files.length}), limiting to ${config.maxFilesToScan}`);
|
|
2175
|
-
const rootConfigs = files.filter((f) => ROOT_CONFIG_FILES.includes(f));
|
|
2176
|
-
const otherFiles = files.filter((f) => !ROOT_CONFIG_FILES.includes(f));
|
|
2177
|
-
const limitedOthers = otherFiles.slice(0, config.maxFilesToScan - rootConfigs.length);
|
|
2178
|
-
return [...rootConfigs, ...limitedOthers];
|
|
2179
|
-
}
|
|
2180
|
-
return files;
|
|
2181
|
-
}
|
|
2182
|
-
async function detectLanguages(projectPath, files, config) {
|
|
2183
|
-
const languageCounts = /* @__PURE__ */ new Map();
|
|
2184
|
-
const languageIndicators = /* @__PURE__ */ new Map();
|
|
2185
|
-
for (const file of files) {
|
|
2186
|
-
const ext = posix.extname(file).toLowerCase();
|
|
2187
|
-
for (const [language, patterns] of Object.entries(LANGUAGE_PATTERNS)) {
|
|
2188
|
-
const extensions = patterns.extensions;
|
|
2189
|
-
if (extensions.includes(ext)) {
|
|
2190
|
-
languageCounts.set(language, (languageCounts.get(language) || 0) + 1);
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
const fileSet = new Set(files);
|
|
2195
|
-
for (const [language, patterns] of Object.entries(LANGUAGE_PATTERNS)) {
|
|
2196
|
-
const indicators = [];
|
|
2197
|
-
for (const file of patterns.files) {
|
|
2198
|
-
if (fileSet.has(file) || fileSet.has(file.toLowerCase())) {
|
|
2199
|
-
indicators.push(`Found ${file}`);
|
|
2200
|
-
languageCounts.set(language, (languageCounts.get(language) || 0) + 10);
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2203
|
-
for (const indicator of patterns.indicators) {
|
|
2204
|
-
if (fileSet.has(indicator) || await pathExists(posix.join(projectPath, indicator))) {
|
|
2205
|
-
indicators.push(`Found ${indicator}`);
|
|
2206
|
-
languageCounts.set(language, (languageCounts.get(language) || 0) + 5);
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
if (indicators.length > 0) {
|
|
2210
|
-
languageIndicators.set(language, new Set(indicators));
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
const totalFiles = files.length;
|
|
2214
|
-
const languages = [];
|
|
2215
|
-
for (const [language, count] of Array.from(languageCounts.entries())) {
|
|
2216
|
-
const confidence = Math.min(count / totalFiles, 1);
|
|
2217
|
-
if (confidence >= config.minConfidence) {
|
|
2218
|
-
languages.push({
|
|
2219
|
-
language,
|
|
2220
|
-
confidence,
|
|
2221
|
-
fileCount: count,
|
|
2222
|
-
indicators: Array.from(languageIndicators.get(language) || [])
|
|
2223
|
-
});
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
return languages;
|
|
2227
|
-
}
|
|
2228
|
-
function detectPackageManager(files) {
|
|
2229
|
-
const managers = {
|
|
2230
|
-
"pnpm-lock.yaml": "pnpm",
|
|
2231
|
-
"yarn.lock": "yarn",
|
|
2232
|
-
"package-lock.json": "npm",
|
|
2233
|
-
"bun.lockb": "bun",
|
|
2234
|
-
"requirements.txt": "pip",
|
|
2235
|
-
"Pipfile": "pipenv",
|
|
2236
|
-
"pyproject.toml": "poetry",
|
|
2237
|
-
"go.mod": "go",
|
|
2238
|
-
"Cargo.toml": "cargo",
|
|
2239
|
-
"pom.xml": "maven",
|
|
2240
|
-
"build.gradle": "gradle"
|
|
2241
|
-
};
|
|
2242
|
-
for (const [file, manager] of Object.entries(managers)) {
|
|
2243
|
-
if (files.includes(file)) {
|
|
2244
|
-
return manager;
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
return void 0;
|
|
2248
|
-
}
|
|
2249
|
-
function detectBuildSystem(files, frameworks) {
|
|
2250
|
-
for (const framework of frameworks) {
|
|
2251
|
-
if (framework.name.includes("next"))
|
|
2252
|
-
return "next";
|
|
2253
|
-
if (framework.name.includes("nuxt"))
|
|
2254
|
-
return "nuxt";
|
|
2255
|
-
if (framework.name.includes("sveltekit"))
|
|
2256
|
-
return "svelte";
|
|
2257
|
-
if (framework.name.includes("astro"))
|
|
2258
|
-
return "unknown";
|
|
2259
|
-
}
|
|
2260
|
-
const buildFiles = {
|
|
2261
|
-
"webpack.config.js": "webpack",
|
|
2262
|
-
"webpack.config.ts": "webpack",
|
|
2263
|
-
"vite.config.ts": "vite",
|
|
2264
|
-
"vite.config.js": "vite",
|
|
2265
|
-
"rollup.config.js": "rollup",
|
|
2266
|
-
"rollup.config.ts": "rollup",
|
|
2267
|
-
"esbuild.config.js": "esbuild",
|
|
2268
|
-
"tsconfig.json": "tsc",
|
|
2269
|
-
".babelrc": "babel",
|
|
2270
|
-
"babel.config.js": "babel",
|
|
2271
|
-
".swcrc": "swc",
|
|
2272
|
-
"Makefile": "make",
|
|
2273
|
-
"CMakeLists.txt": "cmake",
|
|
2274
|
-
"BUILD": "bazel"
|
|
2275
|
-
};
|
|
2276
|
-
for (const [file, system] of Object.entries(buildFiles)) {
|
|
2277
|
-
if (files.includes(file)) {
|
|
2278
|
-
return system;
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
return void 0;
|
|
2282
|
-
}
|
|
2283
|
-
function detectConfigFiles(files) {
|
|
2284
|
-
const configPatterns = [
|
|
2285
|
-
"package.json",
|
|
2286
|
-
"tsconfig.json",
|
|
2287
|
-
"jsconfig.json",
|
|
2288
|
-
"pyproject.toml",
|
|
2289
|
-
"requirements.txt",
|
|
2290
|
-
"setup.py",
|
|
2291
|
-
"go.mod",
|
|
2292
|
-
"Cargo.toml",
|
|
2293
|
-
"pom.xml",
|
|
2294
|
-
"build.gradle",
|
|
2295
|
-
"build.gradle.kts",
|
|
2296
|
-
"composer.json",
|
|
2297
|
-
"Gemfile",
|
|
2298
|
-
"pubspec.yaml",
|
|
2299
|
-
"docker-compose.yml",
|
|
2300
|
-
"docker-compose.yaml",
|
|
2301
|
-
"Dockerfile",
|
|
2302
|
-
".env",
|
|
2303
|
-
".env.example",
|
|
2304
|
-
".gitignore",
|
|
2305
|
-
".dockerignore",
|
|
2306
|
-
"README.md",
|
|
2307
|
-
"readme.md",
|
|
2308
|
-
"README.rst",
|
|
2309
|
-
"readme.rst"
|
|
2310
|
-
];
|
|
2311
|
-
return files.filter((file) => configPatterns.includes(file));
|
|
2312
|
-
}
|
|
2313
|
-
function detectImportantDirs(projectPath) {
|
|
2314
|
-
const importantDirs = [
|
|
2315
|
-
"src",
|
|
2316
|
-
"lib",
|
|
2317
|
-
"app",
|
|
2318
|
-
"public",
|
|
2319
|
-
"static",
|
|
2320
|
-
"assets",
|
|
2321
|
-
"components",
|
|
2322
|
-
"pages",
|
|
2323
|
-
"views",
|
|
2324
|
-
"templates",
|
|
2325
|
-
"styles",
|
|
2326
|
-
"css",
|
|
2327
|
-
"scss",
|
|
2328
|
-
"sass",
|
|
2329
|
-
"less",
|
|
2330
|
-
"tests",
|
|
2331
|
-
"test",
|
|
2332
|
-
"spec",
|
|
2333
|
-
"__tests__",
|
|
2334
|
-
"docs",
|
|
2335
|
-
"doc",
|
|
2336
|
-
"examples",
|
|
2337
|
-
"samples",
|
|
2338
|
-
"scripts",
|
|
2339
|
-
"bin",
|
|
2340
|
-
"tools",
|
|
2341
|
-
"config",
|
|
2342
|
-
"configs",
|
|
2343
|
-
"build",
|
|
2344
|
-
"dist",
|
|
2345
|
-
"out",
|
|
2346
|
-
"target",
|
|
2347
|
-
".github",
|
|
2348
|
-
".vscode",
|
|
2349
|
-
".idea"
|
|
2350
|
-
];
|
|
2351
|
-
const foundDirs = [];
|
|
2352
|
-
for (const dir of importantDirs) {
|
|
2353
|
-
if (existsSync(posix.join(projectPath, dir))) {
|
|
2354
|
-
foundDirs.push(dir);
|
|
2355
|
-
}
|
|
2356
|
-
}
|
|
2357
|
-
return foundDirs;
|
|
2358
|
-
}
|
|
2359
|
-
function determineProjectType(languages, frameworks) {
|
|
2360
|
-
if (languages.length === 0) {
|
|
2361
|
-
return "unknown";
|
|
2362
|
-
}
|
|
2363
|
-
const sortedFrameworks = [...frameworks].sort((a, b) => {
|
|
2364
|
-
const priorityA = FRAMEWORK_PRIORITY[a.name.toLowerCase()] || 0;
|
|
2365
|
-
const priorityB = FRAMEWORK_PRIORITY[b.name.toLowerCase()] || 0;
|
|
2366
|
-
return priorityB - priorityA;
|
|
2367
|
-
});
|
|
2368
|
-
if (sortedFrameworks.length > 0 && sortedFrameworks[0].confidence > 0.7) {
|
|
2369
|
-
return sortedFrameworks[0].name;
|
|
2370
|
-
}
|
|
2371
|
-
return languages[0].language;
|
|
2372
|
-
}
|
|
2373
|
-
function calculateOverallConfidence(languages, frameworks) {
|
|
2374
|
-
if (languages.length === 0)
|
|
2375
|
-
return 0;
|
|
2376
|
-
const langConfidence = languages.reduce((sum, lang) => sum + lang.confidence, 0) / languages.length;
|
|
2377
|
-
let frameworkConfidence = 0;
|
|
2378
|
-
if (frameworks.length > 0) {
|
|
2379
|
-
frameworkConfidence = frameworks.reduce((sum, fw) => sum + fw.confidence, 0) / frameworks.length;
|
|
2380
|
-
}
|
|
2381
|
-
return frameworkConfidence > 0 ? langConfidence * 0.7 + frameworkConfidence * 0.3 : langConfidence;
|
|
2382
|
-
}
|
|
2383
|
-
|
|
2384
|
-
class ProjectAnalyzer {
|
|
2385
|
-
config = {};
|
|
2386
|
-
constructor(config = {}) {
|
|
2387
|
-
this.config = config;
|
|
2388
|
-
}
|
|
2389
|
-
/**
|
|
2390
|
-
* Analyze a project directory
|
|
2391
|
-
*/
|
|
2392
|
-
async analyze(projectPath) {
|
|
2393
|
-
return analyzeProject(projectPath, this.config);
|
|
2394
|
-
}
|
|
2395
|
-
/**
|
|
2396
|
-
* Get project type only
|
|
2397
|
-
*/
|
|
2398
|
-
async getProjectType(projectPath) {
|
|
2399
|
-
return detectProjectType(projectPath);
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
const logger = consola.withTag("analyzer");
|
|
2403
|
-
const DEFAULT_CONFIG = {
|
|
2404
|
-
minConfidence: 0.5,
|
|
2405
|
-
includeNodeModules: false,
|
|
2406
|
-
analyzeTransitiveDeps: true,
|
|
2407
|
-
maxFilesToScan: 1e4,
|
|
2408
|
-
includePatterns: [],
|
|
2409
|
-
excludePatterns: [
|
|
2410
|
-
"node_modules",
|
|
2411
|
-
".git",
|
|
2412
|
-
"dist",
|
|
2413
|
-
"build",
|
|
2414
|
-
"coverage",
|
|
2415
|
-
".vscode",
|
|
2416
|
-
".idea",
|
|
2417
|
-
"*.log",
|
|
2418
|
-
"*.tmp",
|
|
2419
|
-
".DS_Store",
|
|
2420
|
-
"Thumbs.db"
|
|
2421
|
-
]
|
|
2422
|
-
};
|
|
2423
|
-
async function analyzeProject(projectPath, config = {}) {
|
|
2424
|
-
const startTime = Date.now();
|
|
2425
|
-
logger.info(`Analyzing project at: ${projectPath}`);
|
|
2426
|
-
const mergedConfig = {
|
|
2427
|
-
...DEFAULT_CONFIG,
|
|
2428
|
-
...config
|
|
2429
|
-
};
|
|
2430
|
-
try {
|
|
2431
|
-
const analysis = await detectProject(projectPath, mergedConfig);
|
|
2432
|
-
if (mergedConfig.analyzeTransitiveDeps && analysis.dependencies) {
|
|
2433
|
-
analysis.dependencies = await analyzeDependencies$1(analysis, mergedConfig);
|
|
2434
|
-
}
|
|
2435
|
-
analysis.metadata.duration = Date.now() - startTime;
|
|
2436
|
-
logger.success(`Project analysis completed in ${analysis.metadata.duration}ms`);
|
|
2437
|
-
logger.info(`Detected: ${analysis.projectType} (${analysis.metadata.confidence * 100}% confidence)`);
|
|
2438
|
-
return analysis;
|
|
2439
|
-
} catch (error) {
|
|
2440
|
-
logger.error("Project analysis failed:", error);
|
|
2441
|
-
throw new Error(`Failed to analyze project at ${projectPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
async function detectProjectType(projectPath) {
|
|
2445
|
-
const analysis = await analyzeProject(projectPath, {
|
|
2446
|
-
analyzeTransitiveDeps: false
|
|
2447
|
-
});
|
|
2448
|
-
return analysis.projectType;
|
|
2449
|
-
}
|
|
2450
|
-
|
|
2451
|
-
export { ProjectAnalyzer as P, analyzeProject as a };
|