@wtdlee/repomap 0.3.0 → 0.3.1

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.
Files changed (71) hide show
  1. package/dist/analyzers/index.d.ts +69 -5
  2. package/dist/analyzers/index.js +1 -5
  3. package/dist/chunk-3PWXDB7B.js +153 -0
  4. package/dist/{generators/page-map-generator.js → chunk-3YFXZAP7.js} +322 -358
  5. package/dist/chunk-6F4PWJZI.js +1 -0
  6. package/dist/{generators/rails-map-generator.js → chunk-E4WRODSI.js} +86 -94
  7. package/dist/chunk-GNBMJMET.js +2519 -0
  8. package/dist/{server/doc-server.js → chunk-M6YNU536.js} +702 -303
  9. package/dist/chunk-OWM6WNLE.js +2610 -0
  10. package/dist/chunk-SSU6QFTX.js +1058 -0
  11. package/dist/cli.d.ts +0 -1
  12. package/dist/cli.js +348 -452
  13. package/dist/dataflow-analyzer-BfAiqVUp.d.ts +180 -0
  14. package/dist/env-detector-EEMVUEIA.js +1 -0
  15. package/dist/generators/index.d.ts +431 -3
  16. package/dist/generators/index.js +2 -3
  17. package/dist/index.d.ts +53 -10
  18. package/dist/index.js +8 -11
  19. package/dist/page-map-generator-6MJGPBVA.js +1 -0
  20. package/dist/rails-UWSDRS33.js +1 -0
  21. package/dist/rails-map-generator-D2URLMVJ.js +2 -0
  22. package/dist/server/index.d.ts +33 -1
  23. package/dist/server/index.js +7 -1
  24. package/dist/types.d.ts +39 -37
  25. package/dist/types.js +1 -5
  26. package/package.json +4 -2
  27. package/dist/analyzers/base-analyzer.d.ts +0 -45
  28. package/dist/analyzers/base-analyzer.js +0 -47
  29. package/dist/analyzers/dataflow-analyzer.d.ts +0 -29
  30. package/dist/analyzers/dataflow-analyzer.js +0 -425
  31. package/dist/analyzers/graphql-analyzer.d.ts +0 -22
  32. package/dist/analyzers/graphql-analyzer.js +0 -386
  33. package/dist/analyzers/pages-analyzer.d.ts +0 -84
  34. package/dist/analyzers/pages-analyzer.js +0 -1695
  35. package/dist/analyzers/rails/index.d.ts +0 -46
  36. package/dist/analyzers/rails/index.js +0 -145
  37. package/dist/analyzers/rails/rails-controller-analyzer.d.ts +0 -82
  38. package/dist/analyzers/rails/rails-controller-analyzer.js +0 -478
  39. package/dist/analyzers/rails/rails-grpc-analyzer.d.ts +0 -44
  40. package/dist/analyzers/rails/rails-grpc-analyzer.js +0 -262
  41. package/dist/analyzers/rails/rails-model-analyzer.d.ts +0 -88
  42. package/dist/analyzers/rails/rails-model-analyzer.js +0 -493
  43. package/dist/analyzers/rails/rails-react-analyzer.d.ts +0 -41
  44. package/dist/analyzers/rails/rails-react-analyzer.js +0 -529
  45. package/dist/analyzers/rails/rails-routes-analyzer.d.ts +0 -62
  46. package/dist/analyzers/rails/rails-routes-analyzer.js +0 -540
  47. package/dist/analyzers/rails/rails-view-analyzer.d.ts +0 -49
  48. package/dist/analyzers/rails/rails-view-analyzer.js +0 -386
  49. package/dist/analyzers/rails/ruby-parser.d.ts +0 -63
  50. package/dist/analyzers/rails/ruby-parser.js +0 -212
  51. package/dist/analyzers/rest-api-analyzer.d.ts +0 -65
  52. package/dist/analyzers/rest-api-analyzer.js +0 -479
  53. package/dist/core/cache.d.ts +0 -47
  54. package/dist/core/cache.js +0 -151
  55. package/dist/core/engine.d.ts +0 -46
  56. package/dist/core/engine.js +0 -319
  57. package/dist/core/index.d.ts +0 -2
  58. package/dist/core/index.js +0 -2
  59. package/dist/generators/markdown-generator.d.ts +0 -25
  60. package/dist/generators/markdown-generator.js +0 -782
  61. package/dist/generators/mermaid-generator.d.ts +0 -35
  62. package/dist/generators/mermaid-generator.js +0 -364
  63. package/dist/generators/page-map-generator.d.ts +0 -22
  64. package/dist/generators/rails-map-generator.d.ts +0 -21
  65. package/dist/server/doc-server.d.ts +0 -30
  66. package/dist/utils/env-detector.d.ts +0 -31
  67. package/dist/utils/env-detector.js +0 -188
  68. package/dist/utils/parallel.d.ts +0 -23
  69. package/dist/utils/parallel.js +0 -70
  70. package/dist/utils/port.d.ts +0 -15
  71. package/dist/utils/port.js +0 -41
@@ -1,5 +1,69 @@
1
- export * from './base-analyzer.js';
2
- export * from './pages-analyzer.js';
3
- export * from './graphql-analyzer.js';
4
- export * from './dataflow-analyzer.js';
5
- export * from './rest-api-analyzer.js';
1
+ import { B as BaseAnalyzer } from '../dataflow-analyzer-BfAiqVUp.js';
2
+ export { D as DataFlowAnalyzer, G as GraphQLAnalyzer, P as PagesAnalyzer } from '../dataflow-analyzer-BfAiqVUp.js';
3
+ import { RepositoryConfig, AnalysisResult } from '../types.js';
4
+
5
+ /**
6
+ * Analyzer for REST API calls (fetch, axios, useSWR, etc.)
7
+ * REST API呼び出しの分析器
8
+ */
9
+ declare class RestApiAnalyzer extends BaseAnalyzer {
10
+ private project;
11
+ private apiCallCounter;
12
+ constructor(config: RepositoryConfig);
13
+ getName(): string;
14
+ analyze(): Promise<Partial<AnalysisResult>>;
15
+ /**
16
+ * Find fetch() calls
17
+ */
18
+ private findFetchCalls;
19
+ /**
20
+ * Find axios calls (axios.get, axios.post, etc.)
21
+ */
22
+ private findAxiosCalls;
23
+ /**
24
+ * Find useSWR calls
25
+ */
26
+ private findSwrCalls;
27
+ /**
28
+ * Extract API call info from fetch()
29
+ */
30
+ private extractFetchCall;
31
+ /**
32
+ * Extract API call info from axios.method()
33
+ */
34
+ private extractAxiosCall;
35
+ /**
36
+ * Extract API call info from axios() direct call
37
+ */
38
+ private extractAxiosDirectCall;
39
+ /**
40
+ * Extract API call info from useSWR()
41
+ */
42
+ private extractSwrCall;
43
+ /**
44
+ * Get the name of the containing function/component
45
+ */
46
+ private getContainingFunctionName;
47
+ /**
48
+ * Extract URL from argument (handles literals, variables, function calls)
49
+ */
50
+ private extractUrlFromArg;
51
+ /**
52
+ * Clean string literal (remove quotes)
53
+ */
54
+ private cleanStringLiteral;
55
+ /**
56
+ * Check if URL looks like an API endpoint
57
+ */
58
+ private isApiUrl;
59
+ /**
60
+ * Categorize API by URL pattern
61
+ */
62
+ private categorizeApi;
63
+ /**
64
+ * Normalize HTTP method
65
+ */
66
+ private normalizeMethod;
67
+ }
68
+
69
+ export { BaseAnalyzer, RestApiAnalyzer };
@@ -1,5 +1 @@
1
- export * from './base-analyzer.js';
2
- export * from './pages-analyzer.js';
3
- export * from './graphql-analyzer.js';
4
- export * from './dataflow-analyzer.js';
5
- export * from './rest-api-analyzer.js';
1
+ export { BaseAnalyzer, DataFlowAnalyzer, GraphQLAnalyzer, PagesAnalyzer, RestApiAnalyzer } from '../chunk-GNBMJMET.js';
@@ -0,0 +1,153 @@
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
3
+
4
+ // src/utils/env-detector.ts
5
+ async function detectEnvironments(rootPath) {
6
+ const environments = [];
7
+ const railsEnv = await detectRails(rootPath);
8
+ if (railsEnv.detected) {
9
+ environments.push(railsEnv);
10
+ }
11
+ const jsEnv = await detectJsEnvironment(rootPath);
12
+ if (jsEnv.detected) {
13
+ environments.push(jsEnv);
14
+ }
15
+ const hasNextjs = environments.some((e) => e.type === "nextjs");
16
+ const hasReact = environments.some((e) => e.type === "react" || e.type === "nextjs");
17
+ const hasRails = environments.some((e) => e.type === "rails");
18
+ let primary = "generic";
19
+ if (hasNextjs) {
20
+ primary = "nextjs";
21
+ } else if (hasReact) {
22
+ primary = "react";
23
+ } else if (hasRails) {
24
+ primary = "rails";
25
+ }
26
+ return {
27
+ environments,
28
+ hasNextjs,
29
+ hasReact,
30
+ hasRails,
31
+ primary
32
+ };
33
+ }
34
+ async function detectRails(rootPath) {
35
+ const result = {
36
+ type: "rails",
37
+ detected: false,
38
+ path: rootPath,
39
+ features: []
40
+ };
41
+ try {
42
+ const gemfilePath = path.join(rootPath, "Gemfile");
43
+ const routesPath = path.join(rootPath, "config", "routes.rb");
44
+ await fs.access(gemfilePath);
45
+ await fs.access(routesPath);
46
+ const gemfile = await fs.readFile(gemfilePath, "utf-8");
47
+ const isRails = gemfile.includes("gem 'rails'") || gemfile.includes('gem "rails"');
48
+ if (!isRails) {
49
+ return result;
50
+ }
51
+ result.detected = true;
52
+ const versionMatch = gemfile.match(/gem ['"]rails['"],\s*['"]([^'"]+)['"]/);
53
+ if (versionMatch) {
54
+ result.version = versionMatch[1];
55
+ }
56
+ const features = [];
57
+ try {
58
+ await fs.access(path.join(rootPath, "app", "grpc_services"));
59
+ features.push("grpc");
60
+ } catch {
61
+ }
62
+ try {
63
+ const appConfig = await fs.readFile(path.join(rootPath, "config", "application.rb"), "utf-8");
64
+ if (appConfig.includes("config.api_only = true")) {
65
+ features.push("api-only");
66
+ }
67
+ } catch {
68
+ }
69
+ if (gemfile.includes("gem 'graphql'") || gemfile.includes('gem "graphql"')) {
70
+ features.push("graphql");
71
+ }
72
+ if (gemfile.includes("gem 'devise'") || gemfile.includes('gem "devise"')) {
73
+ features.push("devise");
74
+ }
75
+ result.features = features;
76
+ } catch {
77
+ }
78
+ return result;
79
+ }
80
+ async function detectJsEnvironment(rootPath) {
81
+ const result = {
82
+ type: "react",
83
+ detected: false,
84
+ path: rootPath,
85
+ features: []
86
+ };
87
+ try {
88
+ const packageJsonPath = path.join(rootPath, "package.json");
89
+ const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
90
+ const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
91
+ if (!deps["react"]) {
92
+ return result;
93
+ }
94
+ result.detected = true;
95
+ result.version = deps["react"];
96
+ const features = [];
97
+ if (deps["next"]) {
98
+ result.type = "nextjs";
99
+ result.version = deps["next"];
100
+ try {
101
+ await fs.access(path.join(rootPath, "app"));
102
+ features.push("app-router");
103
+ } catch {
104
+ }
105
+ try {
106
+ await fs.access(path.join(rootPath, "pages"));
107
+ features.push("pages-router");
108
+ } catch {
109
+ }
110
+ try {
111
+ await fs.access(path.join(rootPath, "src", "pages"));
112
+ features.push("pages-router");
113
+ } catch {
114
+ }
115
+ try {
116
+ await fs.access(path.join(rootPath, "src", "app"));
117
+ features.push("app-router");
118
+ } catch {
119
+ }
120
+ }
121
+ if (deps["@apollo/client"] || deps["graphql"] || deps["graphql-request"] || deps["urql"]) {
122
+ features.push("graphql");
123
+ }
124
+ if (deps["typescript"]) {
125
+ features.push("typescript");
126
+ }
127
+ if (deps["redux"] || deps["@reduxjs/toolkit"]) {
128
+ features.push("redux");
129
+ }
130
+ if (deps["zustand"]) {
131
+ features.push("zustand");
132
+ }
133
+ if (deps["jotai"] || deps["recoil"]) {
134
+ features.push("atomic-state");
135
+ }
136
+ result.features = features;
137
+ } catch {
138
+ }
139
+ return result;
140
+ }
141
+ function getAnalyzersForEnvironments(envResult) {
142
+ const frontend = [];
143
+ const backend = [];
144
+ if (envResult.hasNextjs || envResult.hasReact) {
145
+ frontend.push("pages", "graphql", "dataflow", "rest-api");
146
+ }
147
+ if (envResult.hasRails) {
148
+ backend.push("routes", "controllers", "models", "grpc");
149
+ }
150
+ return { frontend, backend };
151
+ }
152
+
153
+ export { detectEnvironments, getAnalyzersForEnvironments };