@basemachina/bm-action-dep-parser 0.0.3 → 0.1.0

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/README.md CHANGED
@@ -31,7 +31,8 @@ BaseMachina アクション依存関係解析ツール
31
31
  - 変数に格納されたアクション識別子も検出
32
32
  - JSON形式で結果を出力
33
33
  - **ビューのエントリーポイント分析**: ビューのエントリーポイントから直接・間接的に依存しているすべてのアクションを可視化(ビューは常にエントリーポイント分析モード)
34
- - **カスタムエントリーポイントパターン**: エントリーポイントを柔軟に指定可能(デフォルトは `pages/**/*.{tsx,jsx,ts,js}`)
34
+ - **カスタムエントリーポイントパターン**: エントリーポイントを柔軟に指定可能(デフォルトは `pages/**/*.{tsx,jsx,ts,js}` と `*.{tsx,jsx,ts,js}` で、ネスト構造とフラット構造の両方に対応)
35
+ - **アクション識別子によるフィルタリング**: 特定のアクションに依存するビューやアクションのみを抽出し、変更影響範囲の分析を効率化
35
36
 
36
37
  ### 出力例
37
38
 
@@ -74,16 +75,50 @@ npx @basemachina/bm-action-dep-parser view ./packages/views
74
75
  ### オプション
75
76
 
76
77
  ```bash
77
- # 出力形式を指定(text または json)
78
- npx @basemachina/bm-action-dep-parser action ./packages/actions/js --format json
79
-
80
78
  # カスタムエントリーポイントパターンを指定(ビューの場合のみ)
81
79
  npx @basemachina/bm-action-dep-parser view ./packages/views --entry-point-patterns "**/*.tsx"
82
80
 
81
+ # 特定のアクションに依存するビューのみを抽出
82
+ npx @basemachina/bm-action-dep-parser view ./packages/views --filter-action get-users
83
+
84
+ # 複数のアクションでフィルタリング(OR論理)
85
+ npx @basemachina/bm-action-dep-parser view ./packages/views --filter-action get-users,update-category
86
+
87
+ # アクション解析でもフィルタリング可能
88
+ npx @basemachina/bm-action-dep-parser action ./packages/actions/js --filter-action base-action
89
+
83
90
  # ヘルプを表示
84
91
  npx @basemachina/bm-action-dep-parser --help
85
92
  ```
86
93
 
94
+ ### フィルタリング機能の使用例
95
+
96
+ 特定のアクションの変更影響範囲を分析する場合:
97
+
98
+ ```bash
99
+ # get-usersアクションに依存するビューを特定
100
+ npx @basemachina/bm-action-dep-parser view ./packages/views --filter-action get-users
101
+
102
+ # 出力: get-usersを直接または間接的に使用するビューのみが表示される
103
+ [
104
+ {
105
+ "entrypoint": "pages/UserListPage.tsx",
106
+ "dependencies": {
107
+ "direct": ["get-users"],
108
+ "indirect": {}
109
+ }
110
+ }
111
+ ]
112
+ ```
113
+
114
+ 存在しないアクション識別子を指定した場合、警告メッセージが標準エラー出力に表示されます:
115
+
116
+ ```
117
+ Warning: Action identifier 'nonexistent-action' not found in dependency graph
118
+ No dependencies found for the specified action identifier(s)
119
+ []
120
+ ```
121
+
87
122
  ### ローカルでの実行
88
123
 
89
124
  ```bash
@@ -97,11 +132,14 @@ pnpm run analyze view ./packages/views
97
132
 
98
133
  1. **index.ts**: メインエントリーポイント
99
134
  2. **cli.ts**: コマンドラインインターフェース
100
- 3. **lib/file-finder.ts**: ファイル検索モジュール
101
- 4. **lib/code-analyzer.ts**: コード解析モジュール
102
- 5. **lib/dependency-extractor.ts**: 依存関係抽出モジュール
103
- 6. **lib/result-formatter.ts**: 結果出力モジュール
104
- 7. **lib/dependency-graph-builder.ts**: 依存関係グラフ構築モジュール
105
- 8. **lib/entry-point-analyzer.ts**: エントリーポイント解析モジュール
106
-
107
- TypeScriptのコンパイラAPIを使用してコードを解析し、アクション呼び出しを検出しています。エントリーポイント分析モードでは、ファイル間の依存関係も解析して、間接的なアクション依存関係も検出します。
135
+ 3. **analyze-action-dependencies.ts**: メイン解析ロジック
136
+ 4. **lib/file-finder.ts**: ファイル検索モジュール
137
+ 5. **lib/code-analyzer.ts**: コード解析モジュール(TypeScript Compiler API使用)
138
+ 6. **lib/dependency-extractor.ts**: 依存関係抽出モジュール
139
+ 7. **lib/result-formatter.ts**: 結果出力モジュール(JSON形式)
140
+ 8. **lib/dependency-graph-builder.ts**: ビュー依存関係グラフ構築モジュール
141
+ 9. **lib/action-dependency-graph-builder.ts**: アクション依存関係グラフ構築モジュール
142
+ 10. **lib/entry-point-analyzer.ts**: エントリーポイント解析モジュール
143
+ 11. **lib/dependency-filter.ts**: 依存関係フィルタリングモジュール(アクション識別子による逆引き検索)
144
+
145
+ TypeScriptのコンパイラAPIを使用してコードを解析し、アクション呼び出しを検出しています。エントリーポイント分析では、ファイル間の依存関係も解析して、間接的なアクション依存関係も検出します。
@@ -24,6 +24,7 @@ export interface ViewDependency {
24
24
  * @param targetType 解析対象のタイプ ('action' または 'view')
25
25
  * @param targetDir 対象ディレクトリ
26
26
  * @param entryPointPatterns エントリーポイントのパターン(viewの場合のみ使用)
27
+ * @param filterActionIdentifiers フィルタリングするアクション識別子(オプショナル)
27
28
  * @returns 解析結果のオブジェクト
28
29
  */
29
- export declare function analyzeActionDependencies(targetType: TargetType, targetDir: string, entryPointPatterns?: string[]): Promise<JavaScriptActionDependency[] | ViewDependency[]>;
30
+ export declare function analyzeActionDependencies(targetType: TargetType, targetDir: string, entryPointPatterns?: string[], filterActionIdentifiers?: string[]): Promise<JavaScriptActionDependency[] | ViewDependency[]>;
@@ -41,14 +41,16 @@ const dependency_extractor_1 = require("./lib/dependency-extractor");
41
41
  const dependency_graph_builder_1 = require("./lib/dependency-graph-builder");
42
42
  const action_dependency_graph_builder_1 = require("./lib/action-dependency-graph-builder");
43
43
  const entry_point_analyzer_1 = require("./lib/entry-point-analyzer");
44
+ const dependency_filter_1 = require("./lib/dependency-filter");
44
45
  /**
45
46
  * アクション依存関係を解析する関数
46
47
  * @param targetType 解析対象のタイプ ('action' または 'view')
47
48
  * @param targetDir 対象ディレクトリ
48
49
  * @param entryPointPatterns エントリーポイントのパターン(viewの場合のみ使用)
50
+ * @param filterActionIdentifiers フィルタリングするアクション識別子(オプショナル)
49
51
  * @returns 解析結果のオブジェクト
50
52
  */
51
- async function analyzeActionDependencies(targetType, targetDir, entryPointPatterns = entry_point_analyzer_1.defaultEntryPointPatterns) {
53
+ async function analyzeActionDependencies(targetType, targetDir, entryPointPatterns = entry_point_analyzer_1.defaultEntryPointPatterns, filterActionIdentifiers) {
52
54
  try {
53
55
  // ファイル検索
54
56
  const files = await (0, file_finder_1.findFiles)(targetDir, targetType);
@@ -75,7 +77,7 @@ async function analyzeActionDependencies(targetType, targetDir, entryPointPatter
75
77
  // 依存関係グラフを構築
76
78
  dependencyGraph.buildDependencyGraph();
77
79
  // 各ファイルの依存関係を解析
78
- const result = [];
80
+ let result = [];
79
81
  for (const file of files) {
80
82
  // 依存関係を取得
81
83
  const dependencies = dependencyGraph.getReachableActionDependencies(file);
@@ -95,6 +97,15 @@ async function analyzeActionDependencies(targetType, targetDir, entryPointPatter
95
97
  });
96
98
  }
97
99
  }
100
+ // フィルタリングを適用
101
+ if (filterActionIdentifiers && filterActionIdentifiers.length > 0) {
102
+ const filterResult = (0, dependency_filter_1.filterActionDependencies)(result, filterActionIdentifiers);
103
+ // 警告メッセージを標準エラー出力に表示
104
+ for (const warning of filterResult.warnings) {
105
+ console.error(warning);
106
+ }
107
+ result = filterResult.filtered;
108
+ }
98
109
  return result;
99
110
  }
100
111
  // ビューの場合
@@ -107,13 +118,22 @@ async function analyzeActionDependencies(targetType, targetDir, entryPointPatter
107
118
  // エントリーポイントからの依存関係を解析
108
119
  const entryPointDependencies = await (0, entry_point_analyzer_1.analyzeEntryPoints)(targetDir, dependencyGraph, entryPointPatterns);
109
120
  // 新しい形式に変換
110
- const result = [];
121
+ let result = [];
111
122
  for (const [entryPoint, deps] of Object.entries(entryPointDependencies)) {
112
123
  result.push({
113
124
  entrypoint: entryPoint,
114
125
  dependencies: deps
115
126
  });
116
127
  }
128
+ // フィルタリングを適用
129
+ if (filterActionIdentifiers && filterActionIdentifiers.length > 0) {
130
+ const filterResult = (0, dependency_filter_1.filterViewDependencies)(result, filterActionIdentifiers);
131
+ // 警告メッセージを標準エラー出力に表示
132
+ for (const warning of filterResult.warnings) {
133
+ console.error(warning);
134
+ }
135
+ result = filterResult.filtered;
136
+ }
117
137
  return result;
118
138
  }
119
139
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"analyze-action-dependencies.js","sourceRoot":"","sources":["../analyze-action-dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,8DA2FC;AAnID,2CAA6B;AAC7B,mDAA8C;AAC9C,uDAAkD;AAClD,qEAAiE;AAEjE,6EAAqE;AACrE,2FAA8E;AAC9E,qEAA2F;AA0B3F;;;;;;GAMG;AACI,KAAK,UAAU,yBAAyB,CAC7C,UAAsB,EACtB,SAAiB,EACjB,qBAA+B,gDAAyB;IAExD,IAAI,CAAC;QACH,SAAS;QACT,MAAM,KAAK,GAAG,MAAM,IAAA,uBAAS,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAErD,mBAAmB;QACnB,MAAM,YAAY,GAA6B,EAAE,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,IAAA,2BAAW,EAAC,IAAI,CAAC,CAAC;gBACpC,MAAM,gBAAgB,GAAG,IAAA,0CAAmB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBAC9D,YAAY,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,mBAAmB,EAAE,KAAK,CAAC,CAAC;gBACtD,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,WAAW;QACX,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC5B,aAAa;YACb,MAAM,eAAe,GAAG,IAAI,uDAAqB,CAAC,SAAS,CAAC,CAAC;YAC7D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,C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MAAM,IAAA,yCAAkB,EAAC,SAAS,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC;YAExG,WAAW;YACX,MAAM,MAAM,GAAqB,EAAE,CAAC;YAEpC,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBACxE,MAAM,CAAC,IAAI,CAAC;oBACV,UAAU,EAAE,UAAU;oBACtB,YAAY,EAAE,IAAI;iBACnB,CAAC,CAAC;YACL,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"analyze-action-dependencies.js","sourceRoot":"","sources":["../analyze-action-dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,8DAoHC;AA9JD,2CAA6B;AAC7B,mDAA8C;AAC9C,uDAAkD;AAClD,qEAAiE;AAEjE,6EAAqE;AACrE,2FAA8E;AAC9E,qEAA2F;AAC3F,+DAA2F;AA0B3F;;;;;;;GAOG;AACI,KAAK,UAAU,yBAAyB,CAC7C,UAAsB,EACtB,SAAiB,EACjB,qBAA+B,gDAAyB,EACxD,uBAAkC;IAElC,IAAI,CAAC;QACH,SAAS;QACT,MAAM,KAAK,GAAG,MAAM,IAAA,uBAAS,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAErD,mBAAmB;QACnB,MAAM,YAAY,GAA6B,EAAE,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,IAAA,2BAAW,EAAC,IAAI,CAAC,CAAC;gBACpC,MAAM,gBAAgB,GAAG,IAAA,0CAAmB,EAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBAC9D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AAC;gBAClE,MAAM,YAAY,GAAG,IAAA,0CAAsB,EAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;gBAE7E,qBAAqB;gBACrB,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;oBAC5C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC;gBAED,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC;YACjC,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/cli.js CHANGED
@@ -14,13 +14,17 @@ bm-action-dep-parser - BaseMachina アクション依存関係解析ツール
14
14
  bm-action-dep-parser <action|view> <directory> [options]
15
15
 
16
16
  オプション:
17
- --entry-point-patterns <patterns> エントリーポイントのパターンをカンマ区切りで指定 (デフォルト: pages/**/*.{tsx,jsx,ts,js})
18
- --help, -h ヘルプメッセージを表示
17
+ --entry-point-patterns <patterns> エントリーポイントのパターンをカンマ区切りで指定
18
+ (デフォルト: "pages/**/*.{tsx,jsx,ts,js},*.{tsx,jsx,ts,js}")
19
+ --filter-action <identifiers> フィルタリングするアクション識別子をカンマ区切りで指定
20
+ --help, -h ヘルプメッセージを表示
19
21
 
20
22
  例:
21
23
  bm-action-dep-parser action ./packages/actions/js
22
24
  bm-action-dep-parser view ./packages/views
23
25
  bm-action-dep-parser view ./packages/views --entry-point-patterns "pages/*.tsx,components/**/*.tsx"
26
+ bm-action-dep-parser view ./packages/views --filter-action sampleAction
27
+ bm-action-dep-parser action ./packages/actions/js --filter-action action1,action2
24
28
  `);
25
29
  process.exit(0);
26
30
  }
@@ -35,15 +39,29 @@ if (!targetType || !targetDir) {
35
39
  }
36
40
  // オプションの解析
37
41
  let entryPointPatterns = entry_point_analyzer_1.defaultEntryPointPatterns;
42
+ let filterActionIdentifiers = undefined;
38
43
  for (let i = 2; i < args.length; i++) {
39
44
  const arg = args[i];
40
45
  if (arg === '--entry-point-patterns' && i + 1 < args.length) {
41
46
  entryPointPatterns = args[i + 1].split(',');
42
47
  i++;
43
48
  }
49
+ else if (arg === '--filter-action' && i + 1 < args.length) {
50
+ const identifiersArg = args[i + 1];
51
+ if (!identifiersArg || identifiersArg.trim() === '') {
52
+ console.error('エラー: --filter-action オプションには少なくとも1つのアクション識別子を指定してください');
53
+ process.exit(1);
54
+ }
55
+ filterActionIdentifiers = identifiersArg.split(',').map(id => id.trim()).filter(id => id !== '');
56
+ if (filterActionIdentifiers.length === 0) {
57
+ console.error('エラー: --filter-action オプションには有効なアクション識別子を指定してください');
58
+ process.exit(1);
59
+ }
60
+ i++;
61
+ }
44
62
  }
45
63
  // 解析の実行
46
- (0, analyze_action_dependencies_1.analyzeActionDependencies)(targetType, targetDir, entryPointPatterns)
64
+ (0, analyze_action_dependencies_1.analyzeActionDependencies)(targetType, targetDir, entryPointPatterns, filterActionIdentifiers)
47
65
  .then(result => {
48
66
  console.log(JSON.stringify(result, null, 2));
49
67
  })
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";;;AAEA,+EAAsF;AAEtF,qEAAuE;AAEvE,eAAe;AACf,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,cAAc;AACd,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;CAcf,CAAC,CAAC;IACC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,QAAQ;AACR,MAAM,UAAU,GAAG,IAAI,CAAC,C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+1,24 @@
1
+ import { ViewDependency, JavaScriptActionDependency } from '../analyze-action-dependencies';
2
+ /**
3
+ * フィルタリング結果を表す型
4
+ */
5
+ export interface FilterResult<T> {
6
+ /** フィルタリングされた依存関係 */
7
+ filtered: T;
8
+ /** 警告メッセージ(標準エラー出力用) */
9
+ warnings: string[];
10
+ }
11
+ /**
12
+ * ビュー依存関係をアクション識別子でフィルタリング
13
+ * @param dependencies 全ビュー依存関係
14
+ * @param actionIdentifiers フィルタ対象のアクション識別子
15
+ * @returns フィルタされたビュー依存関係と警告メッセージ
16
+ */
17
+ export declare function filterViewDependencies(dependencies: ViewDependency[], actionIdentifiers: string[]): FilterResult<ViewDependency[]>;
18
+ /**
19
+ * アクション依存関係をアクション識別子でフィルタリング
20
+ * @param dependencies 全アクション依存関係
21
+ * @param actionIdentifiers フィルタ対象のアクション識別子
22
+ * @returns フィルタされたアクション依存関係と警告メッセージ
23
+ */
24
+ export declare function filterActionDependencies(dependencies: JavaScriptActionDependency[], actionIdentifiers: string[]): FilterResult<JavaScriptActionDependency[]>;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterViewDependencies = filterViewDependencies;
4
+ exports.filterActionDependencies = filterActionDependencies;
5
+ /**
6
+ * ビュー依存関係をアクション識別子でフィルタリング
7
+ * @param dependencies 全ビュー依存関係
8
+ * @param actionIdentifiers フィルタ対象のアクション識別子
9
+ * @returns フィルタされたビュー依存関係と警告メッセージ
10
+ */
11
+ function filterViewDependencies(dependencies, actionIdentifiers) {
12
+ const warnings = [];
13
+ const identifierSet = new Set(actionIdentifiers);
14
+ // 全依存関係から存在するアクション識別子を収集
15
+ const allActionIds = new Set();
16
+ for (const dep of dependencies) {
17
+ for (const actionId of dep.dependencies.direct) {
18
+ allActionIds.add(actionId);
19
+ }
20
+ for (const indirectActions of Object.values(dep.dependencies.indirect)) {
21
+ for (const actionId of indirectActions) {
22
+ allActionIds.add(actionId);
23
+ }
24
+ }
25
+ }
26
+ // 存在しないアクション識別子について警告を生成
27
+ for (const identifier of identifierSet) {
28
+ if (!allActionIds.has(identifier)) {
29
+ warnings.push(`Warning: Action identifier '${identifier}' not found in dependency graph`);
30
+ }
31
+ }
32
+ // フィルタリング: 指定されたアクションに依存するビューのみを抽出
33
+ const filtered = [];
34
+ for (const dep of dependencies) {
35
+ // 直接依存をフィルタ
36
+ const matchingDirect = dep.dependencies.direct.filter(actionId => identifierSet.has(actionId));
37
+ // 間接依存をフィルタ
38
+ const matchingIndirect = {};
39
+ for (const [file, actions] of Object.entries(dep.dependencies.indirect)) {
40
+ const matchingActions = actions.filter(actionId => identifierSet.has(actionId));
41
+ if (matchingActions.length > 0) {
42
+ matchingIndirect[file] = matchingActions;
43
+ }
44
+ }
45
+ // いずれかに依存している場合、結果に含める
46
+ if (matchingDirect.length > 0 || Object.keys(matchingIndirect).length > 0) {
47
+ filtered.push({
48
+ entrypoint: dep.entrypoint,
49
+ dependencies: {
50
+ direct: matchingDirect,
51
+ indirect: matchingIndirect
52
+ }
53
+ });
54
+ }
55
+ }
56
+ // 結果が空の場合の警告
57
+ if (filtered.length === 0 && identifierSet.size > 0) {
58
+ warnings.push('No dependencies found for the specified action identifier(s)');
59
+ }
60
+ return {
61
+ filtered,
62
+ warnings
63
+ };
64
+ }
65
+ /**
66
+ * アクション依存関係をアクション識別子でフィルタリング
67
+ * @param dependencies 全アクション依存関係
68
+ * @param actionIdentifiers フィルタ対象のアクション識別子
69
+ * @returns フィルタされたアクション依存関係と警告メッセージ
70
+ */
71
+ function filterActionDependencies(dependencies, actionIdentifiers) {
72
+ const warnings = [];
73
+ const identifierSet = new Set(actionIdentifiers);
74
+ // 全依存関係から存在するアクション識別子を収集
75
+ const allActionIds = new Set();
76
+ for (const dep of dependencies) {
77
+ for (const actionId of dep.dependencies.direct) {
78
+ allActionIds.add(actionId);
79
+ }
80
+ for (const indirectActions of Object.values(dep.dependencies.indirect)) {
81
+ for (const actionId of indirectActions) {
82
+ allActionIds.add(actionId);
83
+ }
84
+ }
85
+ }
86
+ // フィルタ対象のアクション自身がエントリーポイントとして存在するか確認
87
+ for (const dep of dependencies) {
88
+ const actionName = dep.entrypoint.replace(/\.(js|ts)$/, '').split('/').pop();
89
+ if (actionName && identifierSet.has(actionName)) {
90
+ allActionIds.add(actionName);
91
+ }
92
+ }
93
+ // 存在しないアクション識別子について警告を生成
94
+ for (const identifier of identifierSet) {
95
+ if (!allActionIds.has(identifier)) {
96
+ warnings.push(`Warning: Action identifier '${identifier}' not found in dependency graph`);
97
+ }
98
+ }
99
+ // フィルタリング: 指定されたアクションに依存するアクション、または指定されたアクション自身を抽出
100
+ const filtered = [];
101
+ for (const dep of dependencies) {
102
+ // フィルタ対象のアクション自身かチェック
103
+ const actionName = dep.entrypoint.replace(/\.(js|ts)$/, '').split('/').pop();
104
+ const isTargetAction = actionName && identifierSet.has(actionName);
105
+ // 直接依存をフィルタ
106
+ const matchingDirect = dep.dependencies.direct.filter(actionId => identifierSet.has(actionId));
107
+ // 間接依存をフィルタ
108
+ const matchingIndirect = {};
109
+ for (const [file, actions] of Object.entries(dep.dependencies.indirect)) {
110
+ const matchingActions = actions.filter(actionId => identifierSet.has(actionId));
111
+ if (matchingActions.length > 0) {
112
+ matchingIndirect[file] = matchingActions;
113
+ }
114
+ }
115
+ // ターゲットアクション自身、またはいずれかに依存している場合、結果に含める
116
+ if (isTargetAction || matchingDirect.length > 0 || Object.keys(matchingIndirect).length > 0) {
117
+ filtered.push({
118
+ entrypoint: dep.entrypoint,
119
+ dependencies: {
120
+ direct: matchingDirect,
121
+ indirect: matchingIndirect
122
+ }
123
+ });
124
+ }
125
+ }
126
+ // 結果が空の場合の警告
127
+ if (filtered.length === 0 && identifierSet.size > 0) {
128
+ warnings.push('No dependencies found for the specified action identifier(s)');
129
+ }
130
+ return {
131
+ filtered,
132
+ warnings
133
+ };
134
+ }
135
+ //# sourceMappingURL=dependency-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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-0,0 +1 @@
1
+ export {};
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dependency_filter_1 = require("../../lib/dependency-filter");
4
+ describe('filterViewDependencies', () => {
5
+ it('should filter view dependencies by a single action identifier', () => {
6
+ const dependencies = [
7
+ {
8
+ entrypoint: 'pages/Page1.tsx',
9
+ dependencies: {
10
+ direct: ['action1', 'action2'],
11
+ indirect: {}
12
+ }
13
+ },
14
+ {
15
+ entrypoint: 'pages/Page2.tsx',
16
+ dependencies: {
17
+ direct: ['action3'],
18
+ indirect: {}
19
+ }
20
+ },
21
+ {
22
+ entrypoint: 'pages/Page3.tsx',
23
+ dependencies: {
24
+ direct: [],
25
+ indirect: {
26
+ 'components/Component1.tsx': ['action1']
27
+ }
28
+ }
29
+ }
30
+ ];
31
+ const result = (0, dependency_filter_1.filterViewDependencies)(dependencies, ['action1']);
32
+ expect(result.filtered).toHaveLength(2);
33
+ expect(result.filtered.map(d => d.entrypoint)).toContain('pages/Page1.tsx');
34
+ expect(result.filtered.map(d => d.entrypoint)).toContain('pages/Page3.tsx');
35
+ expect(result.warnings).toHaveLength(0);
36
+ });
37
+ it('should filter view dependencies by multiple action identifiers (OR logic)', () => {
38
+ const dependencies = [
39
+ {
40
+ entrypoint: 'pages/Page1.tsx',
41
+ dependencies: {
42
+ direct: ['action1'],
43
+ indirect: {}
44
+ }
45
+ },
46
+ {
47
+ entrypoint: 'pages/Page2.tsx',
48
+ dependencies: {
49
+ direct: ['action2'],
50
+ indirect: {}
51
+ }
52
+ },
53
+ {
54
+ entrypoint: 'pages/Page3.tsx',
55
+ dependencies: {
56
+ direct: ['action3'],
57
+ indirect: {}
58
+ }
59
+ }
60
+ ];
61
+ const result = (0, dependency_filter_1.filterViewDependencies)(dependencies, ['action1', 'action2']);
62
+ expect(result.filtered).toHaveLength(2);
63
+ expect(result.filtered.map(d => d.entrypoint)).toContain('pages/Page1.tsx');
64
+ expect(result.filtered.map(d => d.entrypoint)).toContain('pages/Page2.tsx');
65
+ });
66
+ it('should warn when action identifier is not found', () => {
67
+ const dependencies = [
68
+ {
69
+ entrypoint: 'pages/Page1.tsx',
70
+ dependencies: {
71
+ direct: ['action1'],
72
+ indirect: {}
73
+ }
74
+ }
75
+ ];
76
+ const result = (0, dependency_filter_1.filterViewDependencies)(dependencies, ['nonexistent']);
77
+ expect(result.filtered).toHaveLength(0);
78
+ expect(result.warnings).toHaveLength(2);
79
+ expect(result.warnings[0]).toContain("Warning: Action identifier 'nonexistent' not found");
80
+ expect(result.warnings[1]).toContain('No dependencies found');
81
+ });
82
+ it('should filter partially when some identifiers exist', () => {
83
+ const dependencies = [
84
+ {
85
+ entrypoint: 'pages/Page1.tsx',
86
+ dependencies: {
87
+ direct: ['action1'],
88
+ indirect: {}
89
+ }
90
+ }
91
+ ];
92
+ const result = (0, dependency_filter_1.filterViewDependencies)(dependencies, ['action1', 'nonexistent']);
93
+ expect(result.filtered).toHaveLength(1);
94
+ expect(result.warnings).toHaveLength(1);
95
+ expect(result.warnings[0]).toContain("Warning: Action identifier 'nonexistent' not found");
96
+ });
97
+ it('should filter dependencies array to show only matching actions', () => {
98
+ const dependencies = [
99
+ {
100
+ entrypoint: 'pages/Page1.tsx',
101
+ dependencies: {
102
+ direct: ['action1', 'action2', 'action3'],
103
+ indirect: {
104
+ 'components/Component1.tsx': ['action4', 'action5']
105
+ }
106
+ }
107
+ }
108
+ ];
109
+ const result = (0, dependency_filter_1.filterViewDependencies)(dependencies, ['action1', 'action4']);
110
+ expect(result.filtered).toHaveLength(1);
111
+ expect(result.filtered[0].dependencies.direct).toEqual(['action1']);
112
+ expect(result.filtered[0].dependencies.indirect).toEqual({
113
+ 'components/Component1.tsx': ['action4']
114
+ });
115
+ });
116
+ });
117
+ describe('filterActionDependencies', () => {
118
+ it('should filter action dependencies by a single action identifier', () => {
119
+ const dependencies = [
120
+ {
121
+ entrypoint: 'action1.js',
122
+ dependencies: {
123
+ direct: ['action2'],
124
+ indirect: {}
125
+ }
126
+ },
127
+ {
128
+ entrypoint: 'action3.js',
129
+ dependencies: {
130
+ direct: ['action4'],
131
+ indirect: {}
132
+ }
133
+ }
134
+ ];
135
+ const result = (0, dependency_filter_1.filterActionDependencies)(dependencies, ['action2']);
136
+ expect(result.filtered).toHaveLength(1);
137
+ expect(result.filtered[0].entrypoint).toBe('action1.js');
138
+ });
139
+ it('should include the target action itself if it exists in dependencies', () => {
140
+ const dependencies = [
141
+ {
142
+ entrypoint: 'action1.js',
143
+ dependencies: {
144
+ direct: ['action2'],
145
+ indirect: {}
146
+ }
147
+ },
148
+ {
149
+ entrypoint: 'action2.js',
150
+ dependencies: {
151
+ direct: ['action3'],
152
+ indirect: {}
153
+ }
154
+ }
155
+ ];
156
+ const result = (0, dependency_filter_1.filterActionDependencies)(dependencies, ['action2']);
157
+ expect(result.filtered).toHaveLength(2);
158
+ expect(result.filtered.map(d => d.entrypoint)).toContain('action1.js');
159
+ expect(result.filtered.map(d => d.entrypoint)).toContain('action2.js');
160
+ });
161
+ });
162
+ //# sourceMappingURL=dependency-filter.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependency-filter.test.js","sourceRoot":"","sources":["../../../tests/unit/dependency-filter.test.ts"],"names":[],"mappings":";;AAAA,mEAA+F;AAG/F,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,YAAY,GAAqB;YACrC;gBACE,UAAU,EAAE,iBAAiB;gBAC7B,YAAY,EAAE;oBACZ,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;oBAC9B,QAAQ,EAAE,EAAE;iBACb;aACF;YACD;gBACE,UAAU,EAAE,iBAAiB;gBAC7B,YAAY,EAAE;oBACZ,MAAM,EAAE,CAAC,SAAS,CAAC;oBACnB,QAAQ,EAAE,EAAE;iBACb;aACF;YACD;gBACE,UAAU,EAAE,iBAAiB;gBAC7B,YAAY,EAA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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACvE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemachina/bm-action-dep-parser",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "BaseMachina アクション依存関係解析ツール",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",