@breadstone-tools/localizator-core 0.0.39 → 0.0.40
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/Index.d.ts +4 -4
- package/Index.d.ts.map +1 -1
- package/Index.js +7 -7
- package/Index.js.map +1 -1
- package/Resources/Models/TypeScriptResourceInfo.d.ts +1 -1
- package/Resources/Models/TypeScriptResourceInfo.js +3 -3
- package/Resources/Models/TypeScriptResourceInfo.js.map +1 -1
- package/Resources/Readers/Adapter/Interfaces/IResourceReaderAdapter.d.ts +26 -0
- package/Resources/Readers/Adapter/Interfaces/IResourceReaderAdapter.d.ts.map +1 -0
- package/Resources/Readers/Adapter/Interfaces/IResourceReaderAdapter.js +4 -0
- package/Resources/Readers/Adapter/Interfaces/IResourceReaderAdapter.js.map +1 -0
- package/Resources/Readers/Adapter/JsonResourceReaderAdapter.d.ts +44 -0
- package/Resources/Readers/Adapter/JsonResourceReaderAdapter.d.ts.map +1 -0
- package/Resources/Readers/Adapter/JsonResourceReaderAdapter.js +120 -0
- package/Resources/Readers/Adapter/JsonResourceReaderAdapter.js.map +1 -0
- package/Resources/Readers/Adapter/ResxResourceReaderAdapter.d.ts +44 -0
- package/Resources/Readers/Adapter/ResxResourceReaderAdapter.d.ts.map +1 -0
- package/Resources/Readers/Adapter/ResxResourceReaderAdapter.js +120 -0
- package/Resources/Readers/Adapter/ResxResourceReaderAdapter.js.map +1 -0
- package/Resources/Readers/ResourceReader.d.ts +41 -0
- package/Resources/Readers/ResourceReader.d.ts.map +1 -0
- package/Resources/Readers/ResourceReader.js +77 -0
- package/Resources/Readers/ResourceReader.js.map +1 -0
- package/Resources/ResourceMode.d.ts +10 -4
- package/Resources/ResourceMode.d.ts.map +1 -1
- package/Resources/ResourceMode.js +6 -5
- package/Resources/ResourceMode.js.map +1 -1
- package/Resources/ResourceProcessor.d.ts +3 -3
- package/Resources/ResourceProcessor.d.ts.map +1 -1
- package/Resources/ResourceProcessor.js +4 -4
- package/Resources/ResourceProcessor.js.map +1 -1
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.d.ts +26 -0
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.d.ts.map +1 -0
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.js +4 -0
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.js.map +1 -0
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.d.ts +44 -0
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.d.ts.map +1 -0
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.js +120 -0
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.js.map +1 -0
- package/Resources/Scanners/Adapter/JsonScannerAdapter.d.ts +5 -1
- package/Resources/Scanners/Adapter/JsonScannerAdapter.d.ts.map +1 -1
- package/Resources/Scanners/Adapter/JsonScannerAdapter.js +20 -2
- package/Resources/Scanners/Adapter/JsonScannerAdapter.js.map +1 -1
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.d.ts +44 -0
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.d.ts.map +1 -0
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.js +120 -0
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.js.map +1 -0
- package/Resources/Scanners/Adapter/ResxScannerAdapter.d.ts +5 -1
- package/Resources/Scanners/Adapter/ResxScannerAdapter.d.ts.map +1 -1
- package/Resources/Scanners/Adapter/ResxScannerAdapter.js +20 -2
- package/Resources/Scanners/Adapter/ResxScannerAdapter.js.map +1 -1
- package/Resources/Scanners/ResourceReader.d.ts +41 -0
- package/Resources/Scanners/ResourceReader.d.ts.map +1 -0
- package/Resources/Scanners/ResourceReader.js +77 -0
- package/Resources/Scanners/ResourceReader.js.map +1 -0
- package/Resources/Scanners/ResourceScanner.d.ts +16 -7
- package/Resources/Scanners/ResourceScanner.d.ts.map +1 -1
- package/Resources/Scanners/ResourceScanner.js +32 -14
- package/Resources/Scanners/ResourceScanner.js.map +1 -1
- package/Resources/Transformers/ResourceTransformer.d.ts +3 -3
- package/Resources/Transformers/ResourceTransformer.js +3 -3
- package/package.json +2 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// #region Imports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ResourceReader = void 0;
|
|
5
|
+
const JsonResourceReaderAdapter_1 = require("./Adapter/JsonResourceReaderAdapter");
|
|
6
|
+
const ResourceMode_1 = require("../ResourceMode");
|
|
7
|
+
const ResxResourceReaderAdapter_1 = require("./Adapter/ResxResourceReaderAdapter");
|
|
8
|
+
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
9
|
+
// #endregion
|
|
10
|
+
/**
|
|
11
|
+
* The `ResourceReader` class is responsible for processing resources.
|
|
12
|
+
* It can be resolves json or resx files.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
class ResourceReader {
|
|
17
|
+
// #region Fields
|
|
18
|
+
_fileSystem;
|
|
19
|
+
_logger;
|
|
20
|
+
_adapters;
|
|
21
|
+
// #endregion
|
|
22
|
+
// #region Ctor
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new instance of `ResourceReader`.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
* @param logger - The logger interface.
|
|
28
|
+
* @param fileSystem - The file system interface.
|
|
29
|
+
*/
|
|
30
|
+
constructor(logger, fileSystem) {
|
|
31
|
+
this._fileSystem = fileSystem;
|
|
32
|
+
this._logger = logger;
|
|
33
|
+
this._adapters = new Map()
|
|
34
|
+
.set(ResourceMode_1.ResourceMode.Json, new JsonResourceReaderAdapter_1.JsonResourceReaderAdapter(this._fileSystem, this._logger))
|
|
35
|
+
.set(ResourceMode_1.ResourceMode.Resx, new ResxResourceReaderAdapter_1.ResxResourceReaderAdapter(this._fileSystem, this._logger));
|
|
36
|
+
}
|
|
37
|
+
// #endregion
|
|
38
|
+
// #region Methods
|
|
39
|
+
/**
|
|
40
|
+
* Scans a directory for resources of the given type.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
* @param path - The path to scan.
|
|
44
|
+
* @param type - The type of resource to scan for.
|
|
45
|
+
* @returns An array of resource information found in the directory.
|
|
46
|
+
*/
|
|
47
|
+
scanDirectory(path, type) {
|
|
48
|
+
this._logger.log((0, utilities_1.t) `${(0, utilities_1.magenta)(`Scanning for ${(0, utilities_1.bold)(type)} resources...`)}`);
|
|
49
|
+
const adapter = this._adapters.get(type);
|
|
50
|
+
if (!adapter) {
|
|
51
|
+
throw new Error('No adapter found for the specified mode.');
|
|
52
|
+
}
|
|
53
|
+
const result = adapter.scanDirectory(path);
|
|
54
|
+
this._logger.log((0, utilities_1.t) `${(0, utilities_1.magenta)(`Scanning complete.${result.length === 0 ? (0, utilities_1.yellow)(' No resources found.') : ''}`)}`);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Scans a specific file for resources of the given type.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
* @param path - The path to the file to scan.
|
|
62
|
+
* @param type - The type of resource to scan for.
|
|
63
|
+
* @returns The resource information or null if the file is not a valid resource.
|
|
64
|
+
*/
|
|
65
|
+
scanFile(path, type) {
|
|
66
|
+
this._logger.log((0, utilities_1.t) `${(0, utilities_1.magenta)(`Scanning for ${(0, utilities_1.bold)(type)} resource in file...`)}`);
|
|
67
|
+
const adapter = this._adapters.get(type);
|
|
68
|
+
if (!adapter) {
|
|
69
|
+
throw new Error('No adapter found for the specified mode.');
|
|
70
|
+
}
|
|
71
|
+
const result = adapter.scanFile(path);
|
|
72
|
+
this._logger.log((0, utilities_1.t) `${(0, utilities_1.magenta)(`Scanning complete.${result ? '' : (0, utilities_1.yellow)(' No resource found.')}`)}`);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.ResourceReader = ResourceReader;
|
|
77
|
+
//# sourceMappingURL=ResourceReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceReader.js","sourceRoot":"","sources":["../../../src/Resources/Readers/ResourceReader.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAGlB,mFAAgF;AAEhF,kDAA+C;AAC/C,mFAAgF;AAChF,oEAAgH;AAEhH,aAAa;AAEb;;;;;GAKG;AACH,MAAa,cAAc;IAEvB,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAU;IACjB,SAAS,CAA4C;IAEtE,aAAa;IAEb,eAAe;IAEf;;;;;;OAMG;IACH,YAAmB,MAAe,EAAE,UAAuB;QACvD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAwC;aAC3D,GAAG,CAAC,2BAAY,CAAC,IAAI,EAAE,IAAI,qDAAyB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;aACrF,GAAG,CAAC,2BAAY,CAAC,IAAI,EAAE,IAAI,qDAAyB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/F,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;;OAOG;IACI,aAAa,CAAC,IAAY,EAAE,IAAkB;QACjD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,aAAC,EAAA,GAAG,IAAA,mBAAO,EAAC,gBAAgB,IAAA,gBAAI,EAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAE3E,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,C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declare const ResourceMode: {
|
|
5
7
|
/**
|
|
6
8
|
* `json` - JSON mode.
|
|
7
9
|
*/
|
|
8
|
-
Json
|
|
10
|
+
readonly Json: "json";
|
|
9
11
|
/**
|
|
10
12
|
* `resx` - RESX mode.
|
|
11
13
|
*/
|
|
12
|
-
Resx
|
|
13
|
-
}
|
|
14
|
+
readonly Resx: "resx";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type ResourceMode = (typeof ResourceMode)[keyof typeof ResourceMode];
|
|
14
20
|
//# sourceMappingURL=ResourceMode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceMode.d.ts","sourceRoot":"","sources":["../../src/Resources/ResourceMode.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ResourceMode.d.ts","sourceRoot":"","sources":["../../src/Resources/ResourceMode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY;IAErB;;OAEG;;IAGH;;OAEG;;CAGG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ResourceMode = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* `ResourceMode` - Enum which describes possible options.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
(function (ResourceMode) {
|
|
9
|
+
exports.ResourceMode = {
|
|
9
10
|
/**
|
|
10
11
|
* `json` - JSON mode.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
Json: 'json',
|
|
13
14
|
/**
|
|
14
15
|
* `resx` - RESX mode.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
-
}
|
|
17
|
+
Resx: 'resx'
|
|
18
|
+
};
|
|
18
19
|
//# sourceMappingURL=ResourceMode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceMode.js","sourceRoot":"","sources":["../../src/Resources/ResourceMode.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"ResourceMode.js","sourceRoot":"","sources":["../../src/Resources/ResourceMode.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,YAAY,GAAG;IAExB;;OAEG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM;CAEN,CAAC"}
|
|
@@ -4,7 +4,7 @@ import type { IAnalyzerTaskExecutionContext, IAnalyzerTaskResult } from './Analy
|
|
|
4
4
|
import type { IResourceInfo } from './Models/Interfaces/IResourceInfo';
|
|
5
5
|
import type { ResourceType } from './Models/Interfaces/ResourceType';
|
|
6
6
|
import type { ResourceMode } from './ResourceMode';
|
|
7
|
-
import type {
|
|
7
|
+
import type { ResourceReader } from './Readers/ResourceReader';
|
|
8
8
|
import type { ResourceSorter } from './Sorting/ResourceSorter';
|
|
9
9
|
import type { IResourceTransformerResult } from './Transformers/Interfaces/IResourceTransformerResult';
|
|
10
10
|
import type { ResourceTransformer } from './Transformers/ResourceTransformer';
|
|
@@ -15,7 +15,7 @@ import type { ResourceTransformer } from './Transformers/ResourceTransformer';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class ResourceProcessor {
|
|
17
17
|
private readonly _logger;
|
|
18
|
-
private readonly
|
|
18
|
+
private readonly _reader;
|
|
19
19
|
private readonly _transformer;
|
|
20
20
|
private readonly _analyzer;
|
|
21
21
|
private readonly _sorter;
|
|
@@ -24,7 +24,7 @@ export declare class ResourceProcessor {
|
|
|
24
24
|
*
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
constructor(logger: ILogger,
|
|
27
|
+
constructor(logger: ILogger, reader: ResourceReader, transformer: ResourceTransformer, analyzer: ResourceAnalyzer, sorter: ResourceSorter);
|
|
28
28
|
/**
|
|
29
29
|
* Scans the specified path for resources.
|
|
30
30
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceProcessor.d.ts","sourceRoot":"","sources":["../../src/Resources/ResourceProcessor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACrH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ResourceProcessor.d.ts","sourceRoot":"","sources":["../../src/Resources/ResourceProcessor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACrH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AACvG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E;;;;GAIG;AACH,qBAAa,iBAAiB;IAI1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IAMzC;;;;OAIG;gBACgB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc;IAYhJ;;;;;;;OAOG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC;IAInE;;;;;;;;OAQG;IACI,SAAS,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,GAAG;QAAE,MAAM,EAAE,YAAY,CAAA;KAAE,GAAG,0BAA0B;IAUvJ;;;;;;OAMG;IACI,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,6BAA6B,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAYxG;;;;;;OAMG;IACI,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC;CAMrE"}
|
|
@@ -11,7 +11,7 @@ exports.ResourceProcessor = void 0;
|
|
|
11
11
|
class ResourceProcessor {
|
|
12
12
|
// #region Fields
|
|
13
13
|
_logger;
|
|
14
|
-
|
|
14
|
+
_reader;
|
|
15
15
|
_transformer;
|
|
16
16
|
_analyzer;
|
|
17
17
|
_sorter;
|
|
@@ -22,9 +22,9 @@ class ResourceProcessor {
|
|
|
22
22
|
*
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
|
-
constructor(logger,
|
|
25
|
+
constructor(logger, reader, transformer, analyzer, sorter) {
|
|
26
26
|
this._logger = logger;
|
|
27
|
-
this.
|
|
27
|
+
this._reader = reader;
|
|
28
28
|
this._transformer = transformer;
|
|
29
29
|
this._analyzer = analyzer;
|
|
30
30
|
this._sorter = sorter;
|
|
@@ -40,7 +40,7 @@ class ResourceProcessor {
|
|
|
40
40
|
* @returns The resource information.
|
|
41
41
|
*/
|
|
42
42
|
scan(path, type) {
|
|
43
|
-
return this.
|
|
43
|
+
return this._reader.scanDirectory(path, type);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Transforms an input resource dynamically by determining the appropriate adapter and serializer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceProcessor.js","sourceRoot":"","sources":["../../src/Resources/ResourceProcessor.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAalB,aAAa;AAEb;;;;GAIG;AACH,MAAa,iBAAiB;IAE1B,iBAAiB;IAEA,OAAO,CAAU;IACjB,
|
|
1
|
+
{"version":3,"file":"ResourceProcessor.js","sourceRoot":"","sources":["../../src/Resources/ResourceProcessor.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAalB,aAAa;AAEb;;;;GAIG;AACH,MAAa,iBAAiB;IAE1B,iBAAiB;IAEA,OAAO,CAAU;IACjB,OAAO,CAAiB;IACxB,YAAY,CAAsB;IAClC,SAAS,CAAmB;IAC5B,OAAO,CAAiB;IAEzC,aAAa;IAEb,eAAe;IAEf;;;;OAIG;IACH,YAAmB,MAAe,EAAE,MAAsB,EAAE,WAAgC,EAAE,QAA0B,EAAE,MAAsB;QAC5I,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;;OAOG;IACI,IAAI,CAAC,IAAY,EAAE,IAAkB;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;OAQG;IACI,SAAS,CAAC,QAAuB,EAAE,IAAgF;QACtH,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE9D,OAAO;YACH,gBAAgB,EAAE,QAAQ;YAC1B,mBAAmB,EAAE,WAAW;SACnC,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACI,OAAO,CAAC,KAAoB,EAAE,OAAsC;QACvE,MAAM,OAAO,GAA+B,EAAE,CAAC;QAC/C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAEzD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACI,IAAI,CAAC,SAA+B;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CAIJ;AA9FD,8CA8FC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IResourceInfo } from '../../../Models/Interfaces/IResourceInfo';
|
|
2
|
+
/**
|
|
3
|
+
* The `IResourceReaderAdapter` interface defines the methods for scanning directories and files
|
|
4
|
+
* for resource information. It is used to adapt different resource scanning implementations.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IResourceReaderAdapter {
|
|
9
|
+
/**
|
|
10
|
+
* Scans the specified directory for resource files and returns an array of resource information.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @param path - The path to scan.
|
|
14
|
+
* @returns The resource information.
|
|
15
|
+
*/
|
|
16
|
+
scanDirectory(path: string): Array<IResourceInfo>;
|
|
17
|
+
/**
|
|
18
|
+
* Scans a specific file for resource information.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @param path - The path to the file to scan.
|
|
22
|
+
* @returns The resource information or null if the file is not a valid resource.
|
|
23
|
+
*/
|
|
24
|
+
scanFile(path: string): IResourceInfo | null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=IResourceReaderAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceReaderAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAI9E;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IAInC;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;IAElD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAAC;CAIhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IResourceReaderAdapter.js","sourceRoot":"","sources":["../../../../../src/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.ts"],"names":[],"mappings":";AAAA,kBAAkB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IResourceReaderAdapter } from './Interfaces/IResourceReaderAdapter';
|
|
2
|
+
import type { IJsonResourceInfo } from '../../Models/Interfaces/IJsonResourceInfo';
|
|
3
|
+
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
|
+
/**
|
|
5
|
+
* A resource reader adapter that scans directories for JSON files.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class JsonResourceReaderAdapter implements IResourceReaderAdapter {
|
|
10
|
+
private readonly _fileSystem;
|
|
11
|
+
private readonly _logger;
|
|
12
|
+
private readonly _glob;
|
|
13
|
+
/**
|
|
14
|
+
* Constructs a new instance of the `JsonResourceReaderAdapter` class.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
constructor(fileSystem: IFileSystem, logger: ILogger);
|
|
19
|
+
/**
|
|
20
|
+
* Scans the specified directory for .json files.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @param path - The directory to scan.
|
|
24
|
+
* @returns The resource information.
|
|
25
|
+
*/
|
|
26
|
+
scanDirectory(path: string): Array<IJsonResourceInfo>;
|
|
27
|
+
/**
|
|
28
|
+
* Scans a specific file for resource information.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param path - The path to the file to scan.
|
|
32
|
+
* @returns The resource information or null if the file is not a valid resource.
|
|
33
|
+
*/
|
|
34
|
+
scanFile(path: string): IJsonResourceInfo | null;
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private invalidateDirectory;
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
private invalidateFile;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=JsonResourceReaderAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonResourceReaderAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonResourceReaderAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IAIpE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;IA6B5D;;;;;;OAMG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAqBvD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,cAAc;CAoBzB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// #region Imports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.JsonResourceReaderAdapter = void 0;
|
|
5
|
+
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
6
|
+
const JsonResourceInfo_1 = require("../../Models/JsonResourceInfo");
|
|
7
|
+
const ResourceType_1 = require("../../Models/Interfaces/ResourceType");
|
|
8
|
+
// #endregion
|
|
9
|
+
/**
|
|
10
|
+
* A resource reader adapter that scans directories for JSON files.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
class JsonResourceReaderAdapter {
|
|
15
|
+
// #region Fields
|
|
16
|
+
_fileSystem;
|
|
17
|
+
_logger;
|
|
18
|
+
_glob;
|
|
19
|
+
// #endregion
|
|
20
|
+
// #region Ctor
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new instance of the `JsonResourceReaderAdapter` class.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
constructor(fileSystem, logger) {
|
|
27
|
+
this._fileSystem = fileSystem;
|
|
28
|
+
this._logger = logger;
|
|
29
|
+
this._glob = '**/*.json';
|
|
30
|
+
}
|
|
31
|
+
// #endregion
|
|
32
|
+
// #region Methods
|
|
33
|
+
/**
|
|
34
|
+
* Scans the specified directory for .json files.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
* @param path - The directory to scan.
|
|
38
|
+
* @returns The resource information.
|
|
39
|
+
*/
|
|
40
|
+
scanDirectory(path) {
|
|
41
|
+
this.invalidateDirectory(path);
|
|
42
|
+
const globPath = utilities_1.Path.combine(path, this._glob);
|
|
43
|
+
this._logger.info(` Scanning ${(0, utilities_1.gray)(globPath)}`);
|
|
44
|
+
const scans = this._fileSystem.glob(globPath).map((file) => {
|
|
45
|
+
this._logger.info(` Scanning ${(0, utilities_1.gray)(utilities_1.Path.getFileName(file))}`);
|
|
46
|
+
const json = this._fileSystem.readAllJson(file);
|
|
47
|
+
this._logger.log(` Found ${(0, utilities_1.bold)(Object.keys(json).toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(file))}`);
|
|
48
|
+
return {
|
|
49
|
+
file: file,
|
|
50
|
+
content: () => json
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return scans.map((scan) => new JsonResourceInfo_1.JsonResourceInfo({
|
|
54
|
+
type: ResourceType_1.ResourceType.Json,
|
|
55
|
+
content: scan.content,
|
|
56
|
+
locale: this._fileSystem.getLocale(scan.file),
|
|
57
|
+
name: this._fileSystem.getFileName(scan.file),
|
|
58
|
+
path: scan.file
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Scans a specific file for resource information.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @param path - The path to the file to scan.
|
|
66
|
+
* @returns The resource information or null if the file is not a valid resource.
|
|
67
|
+
*/
|
|
68
|
+
scanFile(path) {
|
|
69
|
+
this.invalidateFile(path);
|
|
70
|
+
const json = this._fileSystem.readAllJson(path);
|
|
71
|
+
if (Object.keys(json).length === 0) {
|
|
72
|
+
this._logger.warn(`The file ${(0, utilities_1.gray)(path)} does not contain any valid JSON data.`);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
this._logger.info(` Found ${(0, utilities_1.bold)(Object.keys(json).length.toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(path))}`);
|
|
76
|
+
return new JsonResourceInfo_1.JsonResourceInfo({
|
|
77
|
+
type: ResourceType_1.ResourceType.Json,
|
|
78
|
+
content: () => json,
|
|
79
|
+
locale: this._fileSystem.getLocale(path),
|
|
80
|
+
name: this._fileSystem.getFileName(path),
|
|
81
|
+
path: path
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
invalidateDirectory(path) {
|
|
88
|
+
if (this._fileSystem.isFileOrDirectory(path) !== 'directory') {
|
|
89
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid directory.`);
|
|
90
|
+
}
|
|
91
|
+
if (!this._fileSystem.exists(path)) {
|
|
92
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
93
|
+
}
|
|
94
|
+
if (this._fileSystem.glob(path).length === 0) {
|
|
95
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} is empty or does not contain any files.`);
|
|
96
|
+
}
|
|
97
|
+
if (this._glob.endsWith(this._glob)) {
|
|
98
|
+
throw new Error(`The path should not end with ${(0, utilities_1.gray)(this._glob)}.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
invalidateFile(path) {
|
|
105
|
+
if (this._fileSystem.isFileOrDirectory(path) !== 'file') {
|
|
106
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid file.`);
|
|
107
|
+
}
|
|
108
|
+
if (!this._fileSystem.exists(path)) {
|
|
109
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
110
|
+
}
|
|
111
|
+
if (!this._fileSystem.glob(path).length) {
|
|
112
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not contain any files.`);
|
|
113
|
+
}
|
|
114
|
+
if (!path.endsWith('.json')) {
|
|
115
|
+
throw new Error('The path should end with .json.');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.JsonResourceReaderAdapter = JsonResourceReaderAdapter;
|
|
120
|
+
//# sourceMappingURL=JsonResourceReaderAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonResourceReaderAdapter.js","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonResourceReaderAdapter.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAIlB,oEAAwG;AACxG,oEAAiE;AACjE,uEAAoE;AAEpE,aAAa;AAEb;;;;GAIG;AACH,MAAa,yBAAyB;IAElC,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAU;IACjB,KAAK,CAAS;IAE/B,aAAa;IAEb,eAAe;IAEf;;;;OAIG;IACH,YAAmB,UAAuB,EAAE,MAAe;QACvD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;IAC7B,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;OAMG;IACI,aAAa,CAAC,IAAY;QAC7B,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAE/B,MAAM,QAA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C;CAIJ;AAvID,8DAuIC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IScannerAdapter } from './Interfaces/
|
|
1
|
+
import type { IScannerAdapter } from './Interfaces/IResourceReaderAdapter';
|
|
2
2
|
import type { IJsonResourceInfo } from '../../Models/Interfaces/IJsonResourceInfo';
|
|
3
3
|
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
4
|
/**
|
|
@@ -24,5 +24,9 @@ export declare class JsonScannerAdapter implements IScannerAdapter {
|
|
|
24
24
|
* @returns The resource information.
|
|
25
25
|
*/
|
|
26
26
|
scan(path: string): Array<IJsonResourceInfo>;
|
|
27
|
+
/**
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
private invalidatePath;
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=JsonScannerAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonScannerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonScannerAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAItD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"JsonScannerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonScannerAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAItD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;IA6BnD;;OAEG;IACH,OAAO,CAAC,cAAc;CAoBzB"}
|
|
@@ -38,9 +38,10 @@ class JsonScannerAdapter {
|
|
|
38
38
|
* @returns The resource information.
|
|
39
39
|
*/
|
|
40
40
|
scan(path) {
|
|
41
|
+
this.invalidatePath(path);
|
|
41
42
|
const globPath = utilities_1.Path.combine(path, this._glob);
|
|
42
43
|
this._logger.info(` Scanning ${(0, utilities_1.gray)(globPath)}`);
|
|
43
|
-
const
|
|
44
|
+
const scans = this._fileSystem.glob(globPath).map((file) => {
|
|
44
45
|
this._logger.info(` Scanning ${(0, utilities_1.gray)(utilities_1.Path.getFileName(file))}`);
|
|
45
46
|
const json = this._fileSystem.readAllJson(file);
|
|
46
47
|
this._logger.log(` Found ${(0, utilities_1.bold)(Object.keys(json).toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(file))}`);
|
|
@@ -49,7 +50,7 @@ class JsonScannerAdapter {
|
|
|
49
50
|
content: () => json
|
|
50
51
|
};
|
|
51
52
|
});
|
|
52
|
-
return
|
|
53
|
+
return scans.map((scan) => new JsonResourceInfo_1.JsonResourceInfo({
|
|
53
54
|
type: ResourceType_1.ResourceType.Json,
|
|
54
55
|
content: scan.content,
|
|
55
56
|
locale: this._fileSystem.getLocale(scan.file),
|
|
@@ -57,6 +58,23 @@ class JsonScannerAdapter {
|
|
|
57
58
|
path: scan.file
|
|
58
59
|
}));
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
invalidatePath(path) {
|
|
65
|
+
if (this._fileSystem.isFileOrDirectory(path) !== 'directory') {
|
|
66
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid directory.`);
|
|
67
|
+
}
|
|
68
|
+
if (!this._fileSystem.exists(path)) {
|
|
69
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
70
|
+
}
|
|
71
|
+
if (this._fileSystem.glob(path).length === 0) {
|
|
72
|
+
throw new Error(`The path ${(0, utilities_1.gray)(path)} is empty or does not contain any files.`);
|
|
73
|
+
}
|
|
74
|
+
if (this._glob.endsWith(this._glob)) {
|
|
75
|
+
throw new Error(`The glob pattern ${(0, utilities_1.gray)(this._glob)} should not end with .json.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
60
78
|
}
|
|
61
79
|
exports.JsonScannerAdapter = JsonScannerAdapter;
|
|
62
80
|
//# sourceMappingURL=JsonScannerAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonScannerAdapter.js","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonScannerAdapter.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAIlB,oEAAwG;AACxG,oEAAiE;AACjE,uEAAoE;AAEpE,aAAa;AAEb;;;;GAIG;AACH,MAAa,kBAAkB;IAE3B,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAU;IACjB,KAAK,CAAS;IAE/B,aAAa;I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AC3D,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACvF,CAAC;IACL,CAAC;CAIJ;AAtFD,gDAsFC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IResourceReaderAdapter } from './Interfaces/IResourceReaderAdapter';
|
|
2
|
+
import type { IResxResourceInfo } from '../../Models/Interfaces/IResxResourceInfo';
|
|
3
|
+
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
|
+
/**
|
|
5
|
+
* A resource reader adapter that scans directories for RESX files.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class ResxResourceReaderAdapter implements IResourceReaderAdapter {
|
|
10
|
+
private readonly _fileSystem;
|
|
11
|
+
private readonly _logger;
|
|
12
|
+
private readonly _glob;
|
|
13
|
+
/**
|
|
14
|
+
* Constructs a new instance of the `ResxResourceReaderAdapter` class.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
constructor(fileSystem: IFileSystem, logger: ILogger);
|
|
19
|
+
/**
|
|
20
|
+
* Scans the specified directory for .resx files.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @param path - The directory to scan.
|
|
24
|
+
* @returns The resource information.
|
|
25
|
+
*/
|
|
26
|
+
scanDirectory(path: string): Array<IResxResourceInfo>;
|
|
27
|
+
/**
|
|
28
|
+
* Scans a specific file for resource information.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param path - The path to the file to scan.
|
|
32
|
+
* @returns The resource information or null if the file is not a valid resource.
|
|
33
|
+
*/
|
|
34
|
+
scanFile(path: string): IResxResourceInfo | null;
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private invalidateDirectory;
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
private invalidateFile;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=ResxResourceReaderAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResxResourceReaderAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/ResxResourceReaderAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IAIpE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;IA6B5D;;;;;;OAMG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAqBvD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,cAAc;CAoBzB"}
|