nodeconfigloder 1.0.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/LICENSE +21 -0
- package/README.md +504 -0
- package/dist/configloder.bundle.js +8053 -0
- package/dist/conftool.bundle.js +11645 -0
- package/dist/finddifferences.bundle.js +396 -0
- package/dist/serializer.bundle.js +4248 -0
- package/dist/src/configloder/ConfigLoder.d.ts +92 -0
- package/dist/src/configloder/ConfigLoder.d.ts.map +1 -0
- package/dist/src/configloder/FindDifferences.d.ts +152 -0
- package/dist/src/configloder/FindDifferences.d.ts.map +1 -0
- package/dist/src/configloder/Serializer.d.ts +108 -0
- package/dist/src/configloder/Serializer.d.ts.map +1 -0
- package/dist/src/tools/index.d.ts +2 -0
- package/dist/src/tools/index.d.ts.map +1 -0
- package/dist/test/unit/configloder/ConfigLoder.test.d.ts +11 -0
- package/dist/test/unit/configloder/ConfigLoder.test.d.ts.map +1 -0
- package/dist/test/unit/configloder/FindDifferences.test.d.ts +11 -0
- package/dist/test/unit/configloder/FindDifferences.test.d.ts.map +1 -0
- package/dist/test/unit/configloder/Serializer.test.d.ts +11 -0
- package/dist/test/unit/configloder/Serializer.test.d.ts.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 nojaja
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
# NodeConfigLoder
|
|
2
|
+
|
|
3
|
+
設定ファイル読み込み・シリアライズライブラリ。
|
|
4
|
+
JSON/YAML形式の設定ファイルを読み込み、暗号化・複号化、差分検出機能を提供します。
|
|
5
|
+
|
|
6
|
+
## Project Overview
|
|
7
|
+
|
|
8
|
+
NodeConfigLoder は Node.js向けの設定管理ライブラリです。以下の機能を提供します:
|
|
9
|
+
|
|
10
|
+
- **設定ファイル読み込み**: JSON/YAML形式の設定ファイルを同期読み込み
|
|
11
|
+
- **データシリアライズ**: 正規表現、Buffer、Secret値を安全にシリアライズ
|
|
12
|
+
- **暗号化サポート**: 機密情報を AES-256-CBC で暗号化・複号化
|
|
13
|
+
- **差分検出**: 設定の変更箇所をハッシュツリーで効率的に検出
|
|
14
|
+
- **CLI ツール**: コマンドラインで設定ファイルを処理
|
|
15
|
+
|
|
16
|
+
## Project Structure
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
src/
|
|
20
|
+
configloder/
|
|
21
|
+
ConfigLoder.js # メインライブラリ - ファイル読み書き
|
|
22
|
+
Serializer.js # シリアライズ・暗号化処理
|
|
23
|
+
FindDifferences.js # 差分検出(ハッシュツリーベース)
|
|
24
|
+
tools/
|
|
25
|
+
index.js # CLIツール実装
|
|
26
|
+
config/
|
|
27
|
+
test.js # テスト用設定ファイルサンプル
|
|
28
|
+
dist/ # ビルド出力ディレクトリ
|
|
29
|
+
webpack.config.js # Webpack設定
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Technology Stack
|
|
33
|
+
|
|
34
|
+
- **Runtime**: Node.js
|
|
35
|
+
- **Bundler**: Webpack 5
|
|
36
|
+
- **Crypto**: Node.js `crypto` モジュール(AES-256-CBC)
|
|
37
|
+
- **YAML**: `js-yaml` 4.1.0
|
|
38
|
+
- **CLI**: `commander` 8.3.0
|
|
39
|
+
- **Testing**: Jest 29.0.0
|
|
40
|
+
- **Utilities**: `@nojaja/pathutil`, `object-path`
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
### ✅ Implemented Features
|
|
45
|
+
|
|
46
|
+
1. **ConfigLoder クラス**
|
|
47
|
+
- `readListSync(filepath)`: テキストファイルを行ごとに読み込む
|
|
48
|
+
- `readConfigSync(filepath)`: JSON/YAMLファイルを読み込む
|
|
49
|
+
- `writeConfigSync(filepath, data)`: JSON/YAMLで出力
|
|
50
|
+
- `toJsonText(json)`: JSON文字列に変換
|
|
51
|
+
- `toYamlText(json)`: YAML文字列に変換
|
|
52
|
+
|
|
53
|
+
2. **Serializer クラス**
|
|
54
|
+
- `serializeObject(json)`: 複雑なオブジェクト(正規表現、Buffer、Secret)をシリアライズ
|
|
55
|
+
- `deserializeObject(json)`: シリアライズ済みオブジェクトを復元
|
|
56
|
+
- `generatekey(password)`: 暗号化キーを生成(scrypt + crypto)
|
|
57
|
+
- AES-256-CBC による暗号化・複号化
|
|
58
|
+
|
|
59
|
+
3. **FindDifferences クラス** ⚠️ 実装進行中
|
|
60
|
+
- `buildHashTree(data)`: ハッシュツリーを構築
|
|
61
|
+
- 変更差分をイベント発行でトラッキング(EventEmitter拡張)
|
|
62
|
+
|
|
63
|
+
4. **CLI ツール**
|
|
64
|
+
- `-i, --input <path>`: 入力設定ファイル(必須)
|
|
65
|
+
- `-o, --output <path>`: 出力ファイルパス
|
|
66
|
+
- `-k, --cryptokey <key>`: 暗号化キー(HEX形式)
|
|
67
|
+
- `-d, --debug`: デバッグログ出力
|
|
68
|
+
- 実行時の処理時間・メモリ使用量を統計出力
|
|
69
|
+
|
|
70
|
+
### config.js で利用可能なオブジェクト
|
|
71
|
+
|
|
72
|
+
設定ファイル(config.js)では以下の特殊なオブジェクトを使用できます。シリアライズ時に自動的に変換されます。
|
|
73
|
+
|
|
74
|
+
| オブジェクトの種類 | config.js での記載例 | 動作 |
|
|
75
|
+
|-----------------|------------------|------|
|
|
76
|
+
| **RegExp** | `/\s@Test\s.*/i` | 正規表現オブジェクト。source・flags・label で保存。復号時に RegExp として復元 |
|
|
77
|
+
| **Buffer** | `Buffer.from('7f454c46','hex')` | バイナリデータ。HEX形式で保存。復号時に Buffer として復元 |
|
|
78
|
+
| **Secret** | `new Secret("secret value")` | 機密情報を暗号化。内容は AES-256-CBC で暗号化して保存 |
|
|
79
|
+
| **Env** | `new Env({ name: 'API_KEY', default: 'fallback' })` | 環境変数を参照。実行時に `process.env[name]` から値を取得、なければ default を使用 |
|
|
80
|
+
|
|
81
|
+
#### RegExp の例(setLabel オプション)
|
|
82
|
+
|
|
83
|
+
RegExp にはラベルを設定でき、マッチした条件判定に利用できます:
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
/\s@Test\s.*/i.setLabel('test-pattern')
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Env の詳細
|
|
90
|
+
|
|
91
|
+
環境変数を動的に設定値に埋め込みます:
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
new Env({
|
|
95
|
+
name: 'DATABASE_URL', // 参照する環境変数名
|
|
96
|
+
default: 'localhost:5432' // フォールバック値
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
実行時に `process.env.DATABASE_URL` が優先され、未設定の場合は `default` が使用されます。
|
|
101
|
+
|
|
102
|
+
### ⚠️ In Progress / Experimental
|
|
103
|
+
|
|
104
|
+
- **FindDifferences**: 差分検出ロジックは実装途上です
|
|
105
|
+
- **イベント駆動**: 大規模ファイルの変更をイベント駆動で通知する予定
|
|
106
|
+
|
|
107
|
+
## Setup
|
|
108
|
+
|
|
109
|
+
### Installation
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
cd NodeConfigLoder
|
|
113
|
+
npm install
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Build
|
|
117
|
+
|
|
118
|
+
開発ビルド(SourceMap付き):
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm run build
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
テストを含むビルド:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run test
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Usage
|
|
131
|
+
|
|
132
|
+
### CLI Tool として利用
|
|
133
|
+
|
|
134
|
+
設定ファイルをコマンドラインから処理します。
|
|
135
|
+
|
|
136
|
+
#### 起動オプション一覧
|
|
137
|
+
|
|
138
|
+
| オプション | 短形式 | 説明 | 必須 |
|
|
139
|
+
|-----------|--------|------|------|
|
|
140
|
+
| `--input <path>` | `-i` | 入力設定ファイルパス | ✅ Yes |
|
|
141
|
+
| `--output <path>` | `-o` | 出力ファイルパス | No(省略時は現在ディレクトリ) |
|
|
142
|
+
| `--cryptokey <key>` | `-k` | 暗号化キー(HEX形式) | No(省略時は自動生成) |
|
|
143
|
+
| `--debug` | `-d` | デバッグログを出力 | No |
|
|
144
|
+
|
|
145
|
+
#### 実行コマンド例
|
|
146
|
+
|
|
147
|
+
**ヘルプ表示**
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
node ./dist/configtool.bundle.js -h
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**基本的な実行例:設定ファイルを処理**
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
node ./dist/configtool.bundle.js -i ./config/test.js -o aa.json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**暗号化キーを指定して実行**
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
node ./dist/configtool.bundle.js -i ./config/test.js -o aa.json -k 0123456789abcdef0123456789abcdef
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**デバッグログを有効にして実行**
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
node ./dist/configtool.bundle.js -i ./config/test.js -o aa.json -d
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**全オプション指定**
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
node ./dist/configtool.bundle.js -i ./config/test.js -o output.json -k a1b2c3d4e5f6... -d
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### 出力内容
|
|
178
|
+
|
|
179
|
+
実行後、以下の情報がコンソールに出力されます:
|
|
180
|
+
|
|
181
|
+
- 入力・出力ファイルパス
|
|
182
|
+
- 使用した暗号化キー(自動生成の場合)
|
|
183
|
+
- 処理結果のオブジェクト内容
|
|
184
|
+
- 実行時間(秒・ミリ秒)
|
|
185
|
+
- メモリ使用量(RSS、ヒープ等)
|
|
186
|
+
|
|
187
|
+
### ライブラリとして利用
|
|
188
|
+
|
|
189
|
+
JavaScript/Node.js コードから ConfigLoder を直接インポートして利用します。
|
|
190
|
+
|
|
191
|
+
#### 基本的な使用例
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
import { ConfigLoder } from './dist/configloder.bundle.js';
|
|
195
|
+
import { Serializer } from './dist/serializer.bundle.js';
|
|
196
|
+
|
|
197
|
+
// 設定ファイルを読み込む
|
|
198
|
+
const loader = new ConfigLoder();
|
|
199
|
+
const config = loader.readConfigSync('./config.json');
|
|
200
|
+
|
|
201
|
+
// シリアライズして暗号化
|
|
202
|
+
const key = Serializer.generatekey('my-password');
|
|
203
|
+
const serializer = new Serializer(key);
|
|
204
|
+
const serialized = serializer.serializeObject(config);
|
|
205
|
+
loader.writeConfigSync('./config.encrypted.json', serialized);
|
|
206
|
+
|
|
207
|
+
// 復号化して読み込む
|
|
208
|
+
const encrypted = loader.readConfigSync('./config.encrypted.json');
|
|
209
|
+
const decrypted = serializer.deserializeObject(encrypted);
|
|
210
|
+
|
|
211
|
+
console.log(decrypted);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### ConfigLoder API
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
const loader = new ConfigLoder(debug = false);
|
|
218
|
+
|
|
219
|
+
// テキストファイルを行ごとに読み込む
|
|
220
|
+
const lines = loader.readListSync('./list.txt'); // string[]
|
|
221
|
+
|
|
222
|
+
// JSON/YAMLファイルを読み込む
|
|
223
|
+
const config = loader.readConfigSync('./config.json');
|
|
224
|
+
|
|
225
|
+
// JSON/YAMLファイルに書き込む
|
|
226
|
+
loader.writeConfigSync('./config.json', configData);
|
|
227
|
+
|
|
228
|
+
// JSON文字列に変換
|
|
229
|
+
const jsonStr = loader.toJsonText(obj);
|
|
230
|
+
|
|
231
|
+
// YAML文字列に変換
|
|
232
|
+
const yamlStr = loader.toYamlText(obj);
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### Serializer API
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
// 暗号化キーを生成(パスワード + ソルトベース)
|
|
239
|
+
const key = Serializer.generatekey('my-password');
|
|
240
|
+
|
|
241
|
+
const serializer = new Serializer(cryptoKey, debug = false);
|
|
242
|
+
|
|
243
|
+
// オブジェクトをシリアライズ(暗号化)
|
|
244
|
+
const serialized = serializer.serializeObject(configString);
|
|
245
|
+
|
|
246
|
+
// シリアライズ済みオブジェクトを復号化
|
|
247
|
+
const deserialized = serializer.deserializeObject(jsonString);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### FindDifferences API ⚠️
|
|
251
|
+
|
|
252
|
+
```javascript
|
|
253
|
+
import { FindDifferences } from './dist/finddifferences.bundle.js';
|
|
254
|
+
|
|
255
|
+
const differ = new FindDifferences();
|
|
256
|
+
|
|
257
|
+
// ハッシュツリーを構築
|
|
258
|
+
const hashTree = differ.buildHashTree(config);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### 開発
|
|
262
|
+
|
|
263
|
+
本プロジェクトの開発に参加する場合の手順です。
|
|
264
|
+
|
|
265
|
+
#### 開発環境のセットアップ
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# リポジトリをクローン
|
|
269
|
+
git clone https://github.com/nojaja/NodeConfigLoder.git
|
|
270
|
+
cd NodeConfigLoder
|
|
271
|
+
|
|
272
|
+
# 依存パッケージをインストール
|
|
273
|
+
npm install
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### ビルド・テスト
|
|
277
|
+
|
|
278
|
+
**開発ビルド**(SourceMap付き)
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
npm run build
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
これは以下と等価です:
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
cross-env NODE_ENV=test webpack
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**テスト実行**
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
npm run test
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
これは以下と等価です:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
cross-env NODE_ENV=test webpack && jest
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
#### 出力ファイル
|
|
303
|
+
|
|
304
|
+
ビルド後、[dist/](dist/) 配下に以下のバンドルが生成されます:
|
|
305
|
+
|
|
306
|
+
| ファイル | 用途 |
|
|
307
|
+
|---------|------|
|
|
308
|
+
| `configloder.bundle.js` | ConfigLoder ライブラリ(UMD) |
|
|
309
|
+
| `serializer.bundle.js` | Serializer ライブラリ(UMD) |
|
|
310
|
+
| `finddifferences.bundle.js` | FindDifferences ライブラリ(UMD) |
|
|
311
|
+
| `configtool.bundle.js` | CLIツール(実行可能) |
|
|
312
|
+
|
|
313
|
+
#### ソースコード構成
|
|
314
|
+
|
|
315
|
+
- [src/configloder/](src/configloder/) - コアライブラリ実装
|
|
316
|
+
- [src/tools/](src/tools/) - CLIツール実装
|
|
317
|
+
- [config/](config/) - テスト用設定ファイル
|
|
318
|
+
- [webpack.config.js](webpack.config.js) - ビルド設定
|
|
319
|
+
|
|
320
|
+
#### 開発ワークフロー
|
|
321
|
+
|
|
322
|
+
1. [src/](src/) 配下のソースコードを編集
|
|
323
|
+
2. `npm run build` でビルド
|
|
324
|
+
3. `npm run test` でテスト実行
|
|
325
|
+
4. 動作確認:`node ./dist/configtool.bundle.js -i ./config/test.js -o aa.json`
|
|
326
|
+
5. 変更を Git にコミット
|
|
327
|
+
|
|
328
|
+
#### デバッグ
|
|
329
|
+
|
|
330
|
+
CLI ツール実行時にデバッグ出力を有効にする:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
node ./dist/configtool.bundle.js -i ./config/test.js -o aa.json -d
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
ライブラリ内のデバッグ出力を有効にする:
|
|
337
|
+
|
|
338
|
+
```javascript
|
|
339
|
+
const loader = new ConfigLoder(true); // debug=true
|
|
340
|
+
const serializer = new Serializer(key, true); // debug=true
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Technical Details
|
|
344
|
+
|
|
345
|
+
### Serialization Format
|
|
346
|
+
|
|
347
|
+
Serializer は複雑なデータ型を JSON 互換形式で保存します:
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
{
|
|
351
|
+
"key1": "value", // 通常の文字列
|
|
352
|
+
"secret": {
|
|
353
|
+
"type": "Secret",
|
|
354
|
+
"iv": "hex string", // 初期化ベクタ
|
|
355
|
+
"hex": "encrypted hex" // 暗号化データ
|
|
356
|
+
},
|
|
357
|
+
"buffer": {
|
|
358
|
+
"type": "Buffer",
|
|
359
|
+
"hex": "7f454c46" // HEX表記
|
|
360
|
+
},
|
|
361
|
+
"regex": {
|
|
362
|
+
"type": "RegExp",
|
|
363
|
+
"source": "\\s@Test\\s.*",
|
|
364
|
+
"flags": "i",
|
|
365
|
+
"label": "optional label" // 任意のラベル
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Encryption Details
|
|
371
|
+
|
|
372
|
+
- **Algorithm**: AES-256-CBC
|
|
373
|
+
- **Key Generation**: `crypto.scryptSync()` (password-based)
|
|
374
|
+
- **IV (初期化ベクタ)**: 各Secret値ごとにランダムに生成
|
|
375
|
+
- **キーは環境変数またはCLI引数で指定**
|
|
376
|
+
|
|
377
|
+
### Test Configuration Example
|
|
378
|
+
|
|
379
|
+
[config/test.js](config/test.js) は以下の構造をサポートしています:
|
|
380
|
+
|
|
381
|
+
```javascript
|
|
382
|
+
module.exports = {
|
|
383
|
+
"key1": "value",
|
|
384
|
+
"key2": new Secret("Secret value"),
|
|
385
|
+
"key3": Buffer.from('7f454c46','hex'),
|
|
386
|
+
"key4": /\s@Test\s.*/i,
|
|
387
|
+
"key5": {
|
|
388
|
+
"key5-1": "value",
|
|
389
|
+
"key5-2": new Secret("Secret value"),
|
|
390
|
+
"key5-3": Buffer.from('7f454c46','hex'),
|
|
391
|
+
},
|
|
392
|
+
"key6": [
|
|
393
|
+
"value",
|
|
394
|
+
new Secret("Secret value"),
|
|
395
|
+
Buffer.from('7f454c46','hex'),
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Current Status
|
|
401
|
+
|
|
402
|
+
| Component | Status | Notes |
|
|
403
|
+
|-----------|--------|-------|
|
|
404
|
+
| ConfigLoder | ✅ Complete | 基本的なファイル I/O 実装済み |
|
|
405
|
+
| Serializer | ✅ Complete | 暗号化・複号化機能実装済み |
|
|
406
|
+
| FindDifferences | ⚠️ In Progress | ハッシュツリー構築中、差分検出ロジック未完 |
|
|
407
|
+
| CLI Tool | ✅ Complete | コマンドラインツール実装済み |
|
|
408
|
+
| Tests | ⚠️ Partial | 基本テストのみ実装 |
|
|
409
|
+
|
|
410
|
+
## Performance / Goals
|
|
411
|
+
|
|
412
|
+
現在のツール特性:
|
|
413
|
+
|
|
414
|
+
- **処理時間**: 実行終了時に秒・ミリ秒単位で統計出力
|
|
415
|
+
- **メモリ使用量**: RSS、ヒープ使用量を MB 単位で出力
|
|
416
|
+
- **目標**: 大規模設定ファイル(数百MB)の差分検出を効率化
|
|
417
|
+
|
|
418
|
+
## Output Example
|
|
419
|
+
|
|
420
|
+
実行時のコンソール出力例:
|
|
421
|
+
|
|
422
|
+
```
|
|
423
|
+
inputPath: D:\devs\workspace202111\NodeConfigLoder\config\test.js
|
|
424
|
+
outputPath: D:\devs\workspace202111\NodeConfigLoder\aa.json
|
|
425
|
+
cryptokey: a1b2c3d4e5f6...
|
|
426
|
+
{ key1: 'value', key2: { type: 'Secret', ... }, ... }
|
|
427
|
+
process statistics - Execution time: 0s 45.123ms, memoryUsage: {"rss":"45.23MB","heapTotal":"32.45MB","heapUsed":"15.67MB",...}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## Quality Baseline
|
|
431
|
+
|
|
432
|
+
本プロジェクトは以下の品質基準を満たしています。
|
|
433
|
+
|
|
434
|
+
### Code Standards
|
|
435
|
+
- **言語**: TypeScript 5.4.5(strict mode)
|
|
436
|
+
- **モジュール形式**: ESM(ES2020)
|
|
437
|
+
- **型カバレッジ**: 100%(`any` 禁止)
|
|
438
|
+
- **ドキュメント**: JSDoc(@param {type}, @returns {type} 必須)
|
|
439
|
+
|
|
440
|
+
### Linting & Code Quality
|
|
441
|
+
- **Linter**: ESLint 8.54.0(Flat-config)
|
|
442
|
+
- @typescript-eslint/eslint-plugin 6.17.0
|
|
443
|
+
- eslint-plugin-sonarjs(Cognitive Complexity ≤10)
|
|
444
|
+
- eslint-plugin-jsdoc(JSDoc validation)
|
|
445
|
+
- **Lint Status**: ✅ 0 errors(`npm run lint`)
|
|
446
|
+
|
|
447
|
+
### Testing
|
|
448
|
+
- **Framework**: Jest 29.7.0 + ts-jest 29.1.1
|
|
449
|
+
- **Test Count**: 27 unit tests
|
|
450
|
+
- **Coverage**:
|
|
451
|
+
- ✅ Statements: 93.38%
|
|
452
|
+
- ✅ **Branches: 85.71%** (target: ≥80%)
|
|
453
|
+
- ✅ Functions: 100%
|
|
454
|
+
- ✅ Lines: 93.18%
|
|
455
|
+
- **Command**: `npm test`
|
|
456
|
+
|
|
457
|
+
### Dependency Management
|
|
458
|
+
- **Tool**: dependency-cruiser
|
|
459
|
+
- **Status**: ✅ No violations(17 modules, 24 dependencies)
|
|
460
|
+
- **Command**: `npm run depcruise`
|
|
461
|
+
|
|
462
|
+
### Build & Bundling
|
|
463
|
+
- **Bundler**: Webpack 5.97.1
|
|
464
|
+
- **Entry Points**: 4 bundles (configloder, conftool, serializer, finddifferences)
|
|
465
|
+
- **Output**: dist/(1.87 MB)
|
|
466
|
+
- **Command**: `npm run build`
|
|
467
|
+
|
|
468
|
+
### Quality Gate (Phase 6)
|
|
469
|
+
全ての品質ゲートが PASS 状態です:
|
|
470
|
+
|
|
471
|
+
| Gate | Command | Status | Details |
|
|
472
|
+
|------|---------|--------|---------|
|
|
473
|
+
| Build | `npm run build` | ✅ PASS | Webpack compilation successful |
|
|
474
|
+
| Lint | `npm run lint` | ✅ PASS | 0 errors, warnings only |
|
|
475
|
+
| Test | `npm test` | ✅ PASS | 27/27 tests, 85.71% branch coverage |
|
|
476
|
+
| Deps | `npm run depcruise` | ✅ PASS | No violations found |
|
|
477
|
+
|
|
478
|
+
### Setup & Commands
|
|
479
|
+
```bash
|
|
480
|
+
# 開発環境セットアップ
|
|
481
|
+
npm install
|
|
482
|
+
|
|
483
|
+
# 開発サーバ起動
|
|
484
|
+
npm run build
|
|
485
|
+
|
|
486
|
+
# テスト実行
|
|
487
|
+
npm test
|
|
488
|
+
|
|
489
|
+
# Lint 実行
|
|
490
|
+
npm run lint
|
|
491
|
+
|
|
492
|
+
# 依存関係検証
|
|
493
|
+
npm run depcruise
|
|
494
|
+
|
|
495
|
+
# ドキュメント生成(設定のみ、手動実行時に `-g typedoc` が必要)
|
|
496
|
+
npm run docs
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
## License & Author
|
|
500
|
+
|
|
501
|
+
- **License**: MIT License © 2025 nojaja
|
|
502
|
+
- **Author**: nojaja <free.riccia@gmail.com>
|
|
503
|
+
- **Repository**: [github.com/nojaja/NodeConfigLoder](https://github.com/nojaja/NodeConfigLoder)
|
|
504
|
+
- **Issues**: [github.com/nojaja/NodeConfigLoder/issues](https://github.com/nojaja/NodeConfigLoder/issues)
|