@basemachina/bm-action-dep-parser 0.0.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.
- package/LICENSE +29 -0
- package/README.md +78 -0
- package/dist/analyze-action-dependencies.d.ts +26 -0
- package/dist/analyze-action-dependencies.js +109 -0
- package/dist/analyze-action-dependencies.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +53 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/code-analyzer.d.ts +7 -0
- package/dist/lib/code-analyzer.js +59 -0
- package/dist/lib/code-analyzer.js.map +1 -0
- package/dist/lib/dependency-extractor.d.ts +9 -0
- package/dist/lib/dependency-extractor.js +97 -0
- package/dist/lib/dependency-extractor.js.map +1 -0
- package/dist/lib/dependency-graph-builder.d.ts +61 -0
- package/dist/lib/dependency-graph-builder.js +289 -0
- package/dist/lib/dependency-graph-builder.js.map +1 -0
- package/dist/lib/entry-point-analyzer.d.ts +20 -0
- package/dist/lib/entry-point-analyzer.js +107 -0
- package/dist/lib/entry-point-analyzer.js.map +1 -0
- package/dist/lib/file-finder.d.ts +8 -0
- package/dist/lib/file-finder.js +30 -0
- package/dist/lib/file-finder.js.map +1 -0
- package/dist/lib/result-formatter.d.ts +15 -0
- package/dist/lib/result-formatter.js +43 -0
- package/dist/lib/result-formatter.js.map +1 -0
- package/dist/tests/e2e/analyze-action-dependencies.test.d.ts +1 -0
- package/dist/tests/e2e/analyze-action-dependencies.test.js +111 -0
- package/dist/tests/e2e/analyze-action-dependencies.test.js.map +1 -0
- package/package.json +48 -0
@@ -0,0 +1,289 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.ViewDependencyGraph = void 0;
|
37
|
+
const ts = __importStar(require("typescript"));
|
38
|
+
const fsPromises = __importStar(require("fs/promises"));
|
39
|
+
const fs = __importStar(require("fs"));
|
40
|
+
const path = __importStar(require("path"));
|
41
|
+
const dependency_extractor_1 = require("./dependency-extractor");
|
42
|
+
/**
|
43
|
+
* ファイル間の依存関係を表すグラフ
|
44
|
+
*/
|
45
|
+
class ViewDependencyGraph {
|
46
|
+
constructor(baseDir) {
|
47
|
+
// ファイル間の依存関係を表すグラフ(キー:ファイルパス、値:依存先ファイルパスのセット)
|
48
|
+
this.graph = new Map();
|
49
|
+
// 各ファイルが直接依存するアクション(キー:ファイルパス、値:アクション識別子のセット)
|
50
|
+
this.directActionDependencies = new Map();
|
51
|
+
// ファイルパスの正規化(絶対パスに変換)
|
52
|
+
this.normalizedPaths = new Map();
|
53
|
+
this.baseDir = path.resolve(baseDir);
|
54
|
+
}
|
55
|
+
/**
|
56
|
+
* ファイルを解析してグラフに追加
|
57
|
+
* @param filePath ファイルパス
|
58
|
+
*/
|
59
|
+
async addFile(filePath) {
|
60
|
+
const normalizedPath = this.normalizePath(filePath);
|
61
|
+
// すでに解析済みの場合はスキップ
|
62
|
+
if (this.graph.has(normalizedPath)) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
try {
|
66
|
+
// ファイルの内容を読み込む
|
67
|
+
const content = await fsPromises.readFile(filePath, 'utf-8');
|
68
|
+
// TypeScriptのパーサーを使用してASTを生成
|
69
|
+
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
70
|
+
// インポート文を解析
|
71
|
+
const imports = this.extractImports(sourceFile, path.dirname(filePath));
|
72
|
+
// JSXコンポーネントの使用を解析
|
73
|
+
const jsxComponents = this.extractJsxComponents(sourceFile, path.dirname(filePath));
|
74
|
+
// 依存するファイルをグラフに追加
|
75
|
+
const dependencies = new Set([...imports, ...jsxComponents]);
|
76
|
+
this.graph.set(normalizedPath, dependencies);
|
77
|
+
// 直接依存するアクションを抽出
|
78
|
+
const actionDependencies = (0, dependency_extractor_1.extractDependencies)(sourceFile, 'view');
|
79
|
+
if (actionDependencies.length > 0) {
|
80
|
+
this.directActionDependencies.set(normalizedPath, new Set(actionDependencies));
|
81
|
+
}
|
82
|
+
// 依存先ファイルも再帰的に解析
|
83
|
+
for (const dependency of dependencies) {
|
84
|
+
if (dependency.endsWith('.tsx') || dependency.endsWith('.jsx') ||
|
85
|
+
dependency.endsWith('.ts') || dependency.endsWith('.js')) {
|
86
|
+
await this.addFile(dependency);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}
|
90
|
+
catch (error) {
|
91
|
+
console.error(`Error analyzing file ${filePath}:`, error);
|
92
|
+
// エラーが発生した場合は空の依存関係を設定
|
93
|
+
this.graph.set(normalizedPath, new Set());
|
94
|
+
}
|
95
|
+
}
|
96
|
+
/**
|
97
|
+
* インポート文からファイルの依存関係を抽出
|
98
|
+
* @param sourceFile TypeScriptのソースファイル
|
99
|
+
* @param basePath インポートパスの解決に使用するベースパス
|
100
|
+
* @returns 依存先ファイルパスの配列
|
101
|
+
*/
|
102
|
+
extractImports(sourceFile, basePath) {
|
103
|
+
const imports = [];
|
104
|
+
// ASTを走査してインポート文を検出
|
105
|
+
function visit(node) {
|
106
|
+
// import文の検出
|
107
|
+
if (ts.isImportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
108
|
+
const importPath = node.moduleSpecifier.text;
|
109
|
+
if (!importPath.startsWith('@') && !importPath.startsWith('.')) {
|
110
|
+
// 外部パッケージのインポートはスキップ
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
imports.push(importPath);
|
114
|
+
}
|
115
|
+
// require文の検出
|
116
|
+
if (ts.isCallExpression(node) &&
|
117
|
+
ts.isIdentifier(node.expression) &&
|
118
|
+
node.expression.text === 'require' &&
|
119
|
+
node.arguments.length > 0 &&
|
120
|
+
ts.isStringLiteral(node.arguments[0])) {
|
121
|
+
const importPath = node.arguments[0].text;
|
122
|
+
if (!importPath.startsWith('@') && !importPath.startsWith('.')) {
|
123
|
+
// 外部パッケージのインポートはスキップ
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
imports.push(importPath);
|
127
|
+
}
|
128
|
+
// 動的インポートの検出
|
129
|
+
if (ts.isCallExpression(node) &&
|
130
|
+
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
|
131
|
+
node.arguments.length > 0 &&
|
132
|
+
ts.isStringLiteral(node.arguments[0])) {
|
133
|
+
const importPath = node.arguments[0].text;
|
134
|
+
if (!importPath.startsWith('@') && !importPath.startsWith('.')) {
|
135
|
+
// 外部パッケージのインポートはスキップ
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
imports.push(importPath);
|
139
|
+
}
|
140
|
+
// 子ノードを再帰的に走査
|
141
|
+
ts.forEachChild(node, visit);
|
142
|
+
}
|
143
|
+
visit(sourceFile);
|
144
|
+
// インポートパスを解決
|
145
|
+
return imports
|
146
|
+
.map(importPath => this.resolveImportPath(importPath, basePath))
|
147
|
+
.filter(Boolean);
|
148
|
+
}
|
149
|
+
/**
|
150
|
+
* JSXコンポーネントの使用からファイルの依存関係を抽出
|
151
|
+
* @param sourceFile TypeScriptのソースファイル
|
152
|
+
* @param basePath インポートパスの解決に使用するベースパス
|
153
|
+
* @returns 依存先ファイルパスの配列
|
154
|
+
*/
|
155
|
+
extractJsxComponents(sourceFile, basePath) {
|
156
|
+
// 現在の実装では、JSXコンポーネントの使用はインポート文から間接的に検出されるため、
|
157
|
+
// 追加の解析は行わない。将来的には、インポートされたコンポーネントとJSX内で使用されている
|
158
|
+
// コンポーネントの対応関係を解析して、より正確な依存関係を構築することも可能。
|
159
|
+
return [];
|
160
|
+
}
|
161
|
+
/**
|
162
|
+
* インポートパスを絶対パスに解決
|
163
|
+
* @param importPath インポートパス
|
164
|
+
* @param basePath インポートパスの解決に使用するベースパス
|
165
|
+
* @returns 解決されたファイルパス
|
166
|
+
*/
|
167
|
+
resolveImportPath(importPath, basePath) {
|
168
|
+
try {
|
169
|
+
if (importPath.startsWith('.')) {
|
170
|
+
// 相対パスの解決
|
171
|
+
let resolvedPath = path.resolve(basePath, importPath);
|
172
|
+
// 拡張子がない場合は追加
|
173
|
+
if (!path.extname(resolvedPath)) {
|
174
|
+
// TypeScriptの拡張子を試す
|
175
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js'];
|
176
|
+
for (const ext of extensions) {
|
177
|
+
const pathWithExt = resolvedPath + ext;
|
178
|
+
try {
|
179
|
+
if (fs.existsSync(pathWithExt)) {
|
180
|
+
return pathWithExt;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
catch (e) {
|
184
|
+
// ファイルが存在しない場合は次の拡張子を試す
|
185
|
+
}
|
186
|
+
}
|
187
|
+
// index.tsxなどを試す
|
188
|
+
for (const ext of extensions) {
|
189
|
+
const indexPath = path.join(resolvedPath, `index${ext}`);
|
190
|
+
try {
|
191
|
+
if (fs.existsSync(indexPath)) {
|
192
|
+
return indexPath;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
catch (e) {
|
196
|
+
// ファイルが存在しない場合は次の拡張子を試す
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
return resolvedPath;
|
201
|
+
}
|
202
|
+
else if (importPath.startsWith('@')) {
|
203
|
+
// エイリアスパスの解決(プロジェクト固有の設定に依存)
|
204
|
+
// 現在の実装では、単純化のためにnullを返す
|
205
|
+
return null;
|
206
|
+
}
|
207
|
+
// 外部パッケージのインポートはnullを返す
|
208
|
+
return null;
|
209
|
+
}
|
210
|
+
catch (error) {
|
211
|
+
console.error(`Error resolving import path ${importPath}:`, error);
|
212
|
+
return null;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
/**
|
216
|
+
* ファイルパスを正規化(絶対パスに変換)
|
217
|
+
* @param filePath ファイルパス
|
218
|
+
* @returns 正規化されたファイルパス
|
219
|
+
*/
|
220
|
+
normalizePath(filePath) {
|
221
|
+
if (this.normalizedPaths.has(filePath)) {
|
222
|
+
return this.normalizedPaths.get(filePath);
|
223
|
+
}
|
224
|
+
const normalizedPath = path.resolve(this.baseDir, filePath);
|
225
|
+
this.normalizedPaths.set(filePath, normalizedPath);
|
226
|
+
return normalizedPath;
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* エントリーポイントから到達可能なすべてのアクション依存関係を取得
|
230
|
+
* @param entryPoint エントリーポイントのファイルパス
|
231
|
+
* @returns 直接依存するアクションと間接依存するアクション(ファイルパスごと)
|
232
|
+
*/
|
233
|
+
getReachableActionDependencies(entryPoint) {
|
234
|
+
const normalizedEntryPoint = this.normalizePath(entryPoint);
|
235
|
+
const visited = new Set();
|
236
|
+
const indirect = new Map();
|
237
|
+
// 深さ優先探索でグラフを走査
|
238
|
+
const dfs = (node) => {
|
239
|
+
if (visited.has(node)) {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
visited.add(node);
|
243
|
+
const dependencies = this.graph.get(node);
|
244
|
+
if (!dependencies) {
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
for (const dependency of dependencies) {
|
248
|
+
const normalizedDependency = this.normalizePath(dependency);
|
249
|
+
// 依存先ファイルが直接依存するアクションを取得
|
250
|
+
const actionDependencies = this.directActionDependencies.get(normalizedDependency);
|
251
|
+
if (actionDependencies && actionDependencies.size > 0) {
|
252
|
+
indirect.set(normalizedDependency, Array.from(actionDependencies));
|
253
|
+
}
|
254
|
+
// 依存先ファイルを再帰的に探索
|
255
|
+
dfs(normalizedDependency);
|
256
|
+
}
|
257
|
+
};
|
258
|
+
// エントリーポイントから探索を開始
|
259
|
+
dfs(normalizedEntryPoint);
|
260
|
+
// エントリーポイント自身が直接依存するアクションを取得
|
261
|
+
const direct = this.directActionDependencies.get(normalizedEntryPoint) || new Set();
|
262
|
+
return {
|
263
|
+
direct: Array.from(direct),
|
264
|
+
indirect
|
265
|
+
};
|
266
|
+
}
|
267
|
+
/**
|
268
|
+
* 依存関係グラフの統計情報を取得
|
269
|
+
* @returns 統計情報
|
270
|
+
*/
|
271
|
+
getStats() {
|
272
|
+
let totalDependencies = 0;
|
273
|
+
for (const dependencies of this.graph.values()) {
|
274
|
+
totalDependencies += dependencies.size;
|
275
|
+
}
|
276
|
+
let totalActionDependencies = 0;
|
277
|
+
for (const actionDependencies of this.directActionDependencies.values()) {
|
278
|
+
totalActionDependencies += actionDependencies.size;
|
279
|
+
}
|
280
|
+
return {
|
281
|
+
totalFiles: this.graph.size,
|
282
|
+
totalDependencies,
|
283
|
+
filesWithActionDependencies: this.directActionDependencies.size,
|
284
|
+
totalActionDependencies
|
285
|
+
};
|
286
|
+
}
|
287
|
+
}
|
288
|
+
exports.ViewDependencyGraph = ViewDependencyGraph;
|
289
|
+
//# sourceMappingURL=dependency-graph-builder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dependency-graph-builder.js","sourceRoot":"","sources":["../../lib/dependency-graph-builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,wDAA0C;AAC1C,uCAAyB;AACzB,2CAA6B;AAC7B,iEAA6D;AAE7D;;GAEG;AACH,MAAa,mBAAmB;IAa9B,YAAY,OAAe;QAZ3B,8CAA8C;QACtC,UAAK,GAA6B,IAAI,GAAG,EAAE,CAAC;QAEpD,8CAA8C;QACtC,6BAAwB,GAA6B,IAAI,GAAG,EAAE,CAAC;QAEvE,sBAAsB;QACd,oBAAe,GAAwB,IAAI,GAAG,EAAE,CAAC;QAMvD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC5B,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAEpD,kBAAkB;QAClB,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;YACnC,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,eAAe;YACf,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAE7D,6BAA6B;YAC7B,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CACpC,QAAQ,EACR,OAAO,EACP,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,CACL,CAAC;YAEF,YAAY;YACZ,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,O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B;gBACjB,GAAG,CAAC,oBAAoB,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;QAEF,mBAAmB;QACnB,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAE1B,6BAA6B;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,IAAI,GAAG,EAAU,CAAC;QAE5F,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAC1B,QAAQ;SACT,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,QAAQ;QAMN,IAAI,iBAAiB,GAAG,CAAC,CAAC;QAC1B,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,iBAAiB,IAAI,YAAY,CAAC,IAAI,CAAC;QACzC,CAAC;QAED,IAAI,uBAAuB,GAAG,CAAC,CAAC;QAChC,KAAK,MAAM,kBAAkB,IAAI,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,EAAE,CAAC;YACxE,uBAAuB,IAAI,kBAAkB,CAAC,IAAI,CAAC;QACrD,CAAC;QAED,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YAC3B,iBAAiB;YACjB,2BAA2B,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI;YAC/D,uBAAuB;SACxB,CAAC;IACJ,CAAC;CACF;AArSD,kDAqSC"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { ViewDependencyGraph } from './dependency-graph-builder';
|
2
|
+
export declare const defaultEntryPointPatterns: string[];
|
3
|
+
/**
|
4
|
+
* 指定されたパターンに一致するファイルをエントリーポイントとして特定
|
5
|
+
* @param viewsDir ビューのディレクトリパス
|
6
|
+
* @param entryPointPatterns エントリーポイントのパターン
|
7
|
+
* @returns エントリーポイントのファイルパスの配列
|
8
|
+
*/
|
9
|
+
export declare function findEntryPoints(viewsDir: string, entryPointPatterns?: string[]): Promise<string[]>;
|
10
|
+
/**
|
11
|
+
* エントリーポイントからの依存関係を解析
|
12
|
+
* @param viewsDir ビューのディレクトリパス
|
13
|
+
* @param dependencyGraph 依存関係グラフ
|
14
|
+
* @param entryPointPatterns エントリーポイントのパターン
|
15
|
+
* @returns エントリーポイントごとの依存関係
|
16
|
+
*/
|
17
|
+
export declare function analyzeEntryPoints(viewsDir: string, dependencyGraph: ViewDependencyGraph, entryPointPatterns?: string[]): Promise<Record<string, {
|
18
|
+
direct: string[];
|
19
|
+
indirect: Record<string, string[]>;
|
20
|
+
}>>;
|
@@ -0,0 +1,107 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.defaultEntryPointPatterns = void 0;
|
37
|
+
exports.findEntryPoints = findEntryPoints;
|
38
|
+
exports.analyzeEntryPoints = analyzeEntryPoints;
|
39
|
+
const path = __importStar(require("path"));
|
40
|
+
const glob_1 = require("glob");
|
41
|
+
exports.defaultEntryPointPatterns = ["pages/**/*.{tsx,jsx,ts,js}"];
|
42
|
+
/**
|
43
|
+
* 指定されたパターンに一致するファイルをエントリーポイントとして特定
|
44
|
+
* @param viewsDir ビューのディレクトリパス
|
45
|
+
* @param entryPointPatterns エントリーポイントのパターン
|
46
|
+
* @returns エントリーポイントのファイルパスの配列
|
47
|
+
*/
|
48
|
+
async function findEntryPoints(viewsDir, entryPointPatterns = exports.defaultEntryPointPatterns) {
|
49
|
+
const files = [];
|
50
|
+
// 各パターンに一致するファイルを検索
|
51
|
+
for (const pattern of entryPointPatterns) {
|
52
|
+
const patternPath = path.join(viewsDir, pattern);
|
53
|
+
const matchedFiles = await (0, glob_1.glob)(patternPath);
|
54
|
+
files.push(...matchedFiles);
|
55
|
+
}
|
56
|
+
// index.tsxファイルを優先
|
57
|
+
const entryPoints = [];
|
58
|
+
const dirToFiles = new Map();
|
59
|
+
for (const file of files) {
|
60
|
+
const dir = path.dirname(file);
|
61
|
+
if (!dirToFiles.has(dir)) {
|
62
|
+
dirToFiles.set(dir, []);
|
63
|
+
}
|
64
|
+
dirToFiles.get(dir).push(file);
|
65
|
+
}
|
66
|
+
for (const [dir, dirFiles] of dirToFiles.entries()) {
|
67
|
+
const indexFile = dirFiles.find(file => path.basename(file).startsWith('index.'));
|
68
|
+
if (indexFile) {
|
69
|
+
entryPoints.push(indexFile);
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
entryPoints.push(...dirFiles);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
return entryPoints;
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* エントリーポイントからの依存関係を解析
|
79
|
+
* @param viewsDir ビューのディレクトリパス
|
80
|
+
* @param dependencyGraph 依存関係グラフ
|
81
|
+
* @param entryPointPatterns エントリーポイントのパターン
|
82
|
+
* @returns エントリーポイントごとの依存関係
|
83
|
+
*/
|
84
|
+
async function analyzeEntryPoints(viewsDir, dependencyGraph, entryPointPatterns = exports.defaultEntryPointPatterns) {
|
85
|
+
// 指定されたパターンに一致するファイルをエントリーポイントとして特定
|
86
|
+
const entryPoints = await findEntryPoints(viewsDir, entryPointPatterns);
|
87
|
+
// 各エントリーポイントの依存関係を解析
|
88
|
+
const result = {};
|
89
|
+
for (const entryPoint of entryPoints) {
|
90
|
+
const dependencies = dependencyGraph.getReachableActionDependencies(entryPoint);
|
91
|
+
// Map<string, string[]>をRecord<string, string[]>に変換
|
92
|
+
const indirectDependencies = {};
|
93
|
+
for (const [file, actions] of dependencies.indirect.entries()) {
|
94
|
+
// ファイルパスをviewsDirからの相対パスに変換
|
95
|
+
const relativePath = path.relative(viewsDir, file);
|
96
|
+
indirectDependencies[relativePath] = actions;
|
97
|
+
}
|
98
|
+
// エントリーポイントをviewsDirからの相対パスに変換
|
99
|
+
const relativeEntryPoint = path.relative(viewsDir, entryPoint);
|
100
|
+
result[relativeEntryPoint] = {
|
101
|
+
direct: dependencies.direct,
|
102
|
+
indirect: indirectDependencies
|
103
|
+
};
|
104
|
+
}
|
105
|
+
return result;
|
106
|
+
}
|
107
|
+
//# sourceMappingURL=entry-point-analyzer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"entry-point-analyzer.js","sourceRoot":"","sources":["../../lib/entry-point-analyzer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,0CAgCC;AASD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C,SAAS,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,QAAgB,EAChB,eAAoC,EACpC,qBAA+B,iCAAyB;IAKxD,oCAAoC;IACpC,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAExE,qBAAqB;IACrB,MAAM,MAAM,GAGP,EAAE,CAAC;IAER,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,YAAY,GAAG,eAAe,CAAC,8BAA8B,CAAC,UAAU,CAAC,CAAC;QAEhF,oDAAoD;QACpD,MAAM,oBAAoB,GAA6B,EAAE,CAAC;QAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YAC9D,4BAA4B;YAC5B,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACnD,oBAAoB,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;QAC/C,CAAC;QAED,+BAA+B;QAC/B,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAE/D,MAAM,CAAC,kBAAkB,CAAC,GAAG;YAC3B,MAAM,EAAE,YAAY,CAAC,MAAM;YAC3B,QAAQ,EAAE,oBAAoB;SAC/B,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { TargetType } from '../analyze-action-dependencies';
|
2
|
+
/**
|
3
|
+
* 指定されたディレクトリ内のファイルを検索する
|
4
|
+
* @param directory 検索対象のディレクトリ
|
5
|
+
* @param targetType 解析対象のタイプ ('action' または 'view')
|
6
|
+
* @returns ファイルパスの配列
|
7
|
+
*/
|
8
|
+
export declare function findFiles(directory: string, targetType: TargetType): Promise<string[]>;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.findFiles = findFiles;
|
7
|
+
const glob_1 = require("glob");
|
8
|
+
const path_1 = __importDefault(require("path"));
|
9
|
+
/**
|
10
|
+
* 指定されたディレクトリ内のファイルを検索する
|
11
|
+
* @param directory 検索対象のディレクトリ
|
12
|
+
* @param targetType 解析対象のタイプ ('action' または 'view')
|
13
|
+
* @returns ファイルパスの配列
|
14
|
+
*/
|
15
|
+
async function findFiles(directory, targetType) {
|
16
|
+
const patterns = [];
|
17
|
+
if (targetType === 'action') {
|
18
|
+
patterns.push('**/*.js', '**/*.ts');
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
patterns.push('**/*.jsx', '**/*.tsx', '**/*.js', '**/*.ts');
|
22
|
+
}
|
23
|
+
const files = [];
|
24
|
+
for (const pattern of patterns) {
|
25
|
+
const matches = await (0, glob_1.glob)(path_1.default.join(directory, pattern));
|
26
|
+
files.push(...matches);
|
27
|
+
}
|
28
|
+
return files;
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=file-finder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-finder.js","sourceRoot":"","sources":["../../lib/file-finder.ts"],"names":[],"mappings":";;;;;AAUA,8BAgBC;AA1BD,+BAA4B;AAC5B,gDAAwB;AAGxB;;;;;GAKG;AACI,KAAK,UAAU,SAAS,CAAC,SAAiB,EAAE,UAAsB;IACvE,MAAM,QAAQ,GAAG,EAAE,CAAC;IAEpB,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;QAC5B,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,MAAM,IAAA,WAAI,EAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1D,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* 依存関係の解析結果をJSON形式でフォーマットする
|
3
|
+
* @param dependencies ファイルパスとそれが依存するアクションのマップ
|
4
|
+
* @returns JSON形式でフォーマットされた結果
|
5
|
+
*/
|
6
|
+
export declare function formatJavaScriptActionDependencyAnalysisResult(dependencies: Record<string, string[]>): string;
|
7
|
+
/**
|
8
|
+
* ビューのエントリーポイント分析結果をJSON形式でフォーマット
|
9
|
+
* @param entryPointDependencies エントリーポイントごとの依存関係
|
10
|
+
* @returns JSON形式でフォーマットされた結果
|
11
|
+
*/
|
12
|
+
export declare function formatViewDependencyAnalysisResult(entryPointDependencies: Record<string, {
|
13
|
+
direct: string[];
|
14
|
+
indirect: Record<string, string[]>;
|
15
|
+
}>): string;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.formatJavaScriptActionDependencyAnalysisResult = formatJavaScriptActionDependencyAnalysisResult;
|
7
|
+
exports.formatViewDependencyAnalysisResult = formatViewDependencyAnalysisResult;
|
8
|
+
const path_1 = __importDefault(require("path"));
|
9
|
+
/**
|
10
|
+
* 依存関係の解析結果をJSON形式でフォーマットする
|
11
|
+
* @param dependencies ファイルパスとそれが依存するアクションのマップ
|
12
|
+
* @returns JSON形式でフォーマットされた結果
|
13
|
+
*/
|
14
|
+
function formatJavaScriptActionDependencyAnalysisResult(dependencies) {
|
15
|
+
const result = [];
|
16
|
+
for (const [file, deps] of Object.entries(dependencies)) {
|
17
|
+
if (deps.length === 0) {
|
18
|
+
continue;
|
19
|
+
}
|
20
|
+
const relativePath = path_1.default.relative(process.cwd(), file);
|
21
|
+
result.push({
|
22
|
+
entrypoint: relativePath,
|
23
|
+
dependencies: deps
|
24
|
+
});
|
25
|
+
}
|
26
|
+
return JSON.stringify(result, null, 2);
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* ビューのエントリーポイント分析結果をJSON形式でフォーマット
|
30
|
+
* @param entryPointDependencies エントリーポイントごとの依存関係
|
31
|
+
* @returns JSON形式でフォーマットされた結果
|
32
|
+
*/
|
33
|
+
function formatViewDependencyAnalysisResult(entryPointDependencies) {
|
34
|
+
const result = [];
|
35
|
+
for (const [entryPoint, deps] of Object.entries(entryPointDependencies)) {
|
36
|
+
result.push({
|
37
|
+
entrypoint: entryPoint,
|
38
|
+
dependencies: deps
|
39
|
+
});
|
40
|
+
}
|
41
|
+
return JSON.stringify(result, null, 2);
|
42
|
+
}
|
43
|
+
//# sourceMappingURL=result-formatter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"result-formatter.js","sourceRoot":"","sources":["../../lib/result-formatter.ts"],"names":[],"mappings":";;;;;AAQA,wGAkBC;AAOD,gFAgBC;AAjDD,gDAAwB;AAGxB;;;;GAIG;AACH,SAAgB,8CAA8C,CAC5D,YAAsC;IAEtC,MAAM,MAAM,GAAiC,EAAE,CAAC;IAEhD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACxD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,SAAS;QACX,CAAC;QAED,MAAM,YAAY,GAAG,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC;YACV,UAAU,EAAE,YAAY;YACxB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,SAAgB,kCAAkC,CAChD,sBAGE;IAEF,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC;YACV,UAAU,EAAE,UAAU;YACtB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
const analyze_action_dependencies_1 = require("../../analyze-action-dependencies");
|
37
|
+
const path = __importStar(require("path"));
|
38
|
+
const fs = __importStar(require("fs"));
|
39
|
+
describe('Action dependencies analysis', () => {
|
40
|
+
it('should correctly analyze action dependencies', async () => {
|
41
|
+
// 関数を直接呼び出し
|
42
|
+
const result = await (0, analyze_action_dependencies_1.analyzeActionDependencies)('action', path.resolve(__dirname, '../fixtures/actions'));
|
43
|
+
// 期待される結果をJSONファイルから読み込む
|
44
|
+
const expectedPath = path.resolve(__dirname, '../fixtures/expected/action-dependencies.json');
|
45
|
+
const expectedJson = fs.readFileSync(expectedPath, 'utf-8');
|
46
|
+
const expected = JSON.parse(expectedJson);
|
47
|
+
// テスト用に相対パスのままで比較
|
48
|
+
expect(result).toEqual(expected);
|
49
|
+
});
|
50
|
+
it('should handle non-existent directory', async () => {
|
51
|
+
try {
|
52
|
+
// 存在しないディレクトリを指定
|
53
|
+
await (0, analyze_action_dependencies_1.analyzeActionDependencies)('action', path.resolve(__dirname, '../fixtures/non-existent'));
|
54
|
+
// エラーが発生しなかった場合はテスト失敗
|
55
|
+
fail('Expected an error to be thrown');
|
56
|
+
}
|
57
|
+
catch (error) {
|
58
|
+
// エラーが発生することを確認
|
59
|
+
expect(error).toBeDefined();
|
60
|
+
}
|
61
|
+
});
|
62
|
+
});
|
63
|
+
describe('View dependencies analysis', () => {
|
64
|
+
it('should correctly analyze view dependencies', async () => {
|
65
|
+
// 関数を直接呼び出し
|
66
|
+
const result = await (0, analyze_action_dependencies_1.analyzeActionDependencies)('view', path.resolve(__dirname, '../fixtures/views'));
|
67
|
+
// 結果をコンソールに出力して確認
|
68
|
+
console.log('View dependencies result:', JSON.stringify(result, null, 2));
|
69
|
+
// 期待される結果をJSONファイルから読み込む
|
70
|
+
const expectedPath = path.resolve(__dirname, '../fixtures/expected/view-dependencies.json');
|
71
|
+
const expectedJson = fs.readFileSync(expectedPath, 'utf-8');
|
72
|
+
const expected = JSON.parse(expectedJson);
|
73
|
+
expect(result).toEqual(expected);
|
74
|
+
});
|
75
|
+
it('should handle empty directory', async () => {
|
76
|
+
// 一時的な空ディレクトリを作成してテスト
|
77
|
+
const tempDir = path.resolve(__dirname, '../fixtures/temp-empty-dir');
|
78
|
+
try {
|
79
|
+
// ディレクトリが存在しない場合は作成
|
80
|
+
const fs = require('fs');
|
81
|
+
if (!fs.existsSync(tempDir)) {
|
82
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
83
|
+
}
|
84
|
+
const result = await (0, analyze_action_dependencies_1.analyzeActionDependencies)('view', tempDir);
|
85
|
+
// 空の配列が返されることを期待
|
86
|
+
expect(result).toEqual([]);
|
87
|
+
}
|
88
|
+
finally {
|
89
|
+
// テスト後にディレクトリを削除
|
90
|
+
const fs = require('fs');
|
91
|
+
if (fs.existsSync(tempDir)) {
|
92
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
93
|
+
}
|
94
|
+
}
|
95
|
+
});
|
96
|
+
});
|
97
|
+
describe('Invalid arguments', () => {
|
98
|
+
it('should handle invalid target type', async () => {
|
99
|
+
try {
|
100
|
+
// TypeScriptの型チェックを回避するためにanyを使用
|
101
|
+
await (0, analyze_action_dependencies_1.analyzeActionDependencies)('invalid-type', './tests/fixtures/views');
|
102
|
+
// エラーが発生しなかった場合はテスト失敗
|
103
|
+
fail('Expected an error to be thrown');
|
104
|
+
}
|
105
|
+
catch (error) {
|
106
|
+
// エラーが発生することを確認
|
107
|
+
expect(error).toBeDefined();
|
108
|
+
}
|
109
|
+
});
|
110
|
+
});
|
111
|
+
//# sourceMappingURL=analyze-action-dependencies.test.js.map
|