@yamato-daiwa/es-extensions-nodejs 1.6.0-rc.2 → 1.6.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/Distributable/ConsoleCommandsParser/ConsoleCommandsParser.d.ts +22 -17
- package/Distributable/ConsoleCommandsParser/ConsoleCommandsParser.js +14 -2
- package/Distributable/ConsoleCommandsParser/ConsoleCommandsParserLocalization.english.js +7 -6
- package/Distributable/ImprovedGlob.js +3 -3
- package/Distributable/ObjectDataFilesProcessor/ObjectDataFilesProcessor.d.ts +1 -1
- package/Distributable/ObjectDataFilesProcessor/ObjectDataFilesProcessor.js +1 -1
- package/Distributable/ObjectDataFilesProcessor/ObjectDataFilesProcessorLocalization.english.js +1 -1
- package/Distributable/index.d.ts +2 -2
- package/Distributable/index.js +2 -2
- package/LICENSE +1 -1
- package/README.md +3 -9
- package/package.json +3 -2
|
@@ -49,34 +49,38 @@ declare namespace ConsoleCommandsParser {
|
|
|
49
49
|
}>;
|
|
50
50
|
type OptionSpecification = Readonly<{
|
|
51
51
|
description?: string;
|
|
52
|
-
}> & (StringOptionSpecification | NumberOptionSpecification | BooleanParameterSpecification | JSON5_ParameterSpecification);
|
|
53
|
-
type ParameterSpecification__CommonProperties = Readonly<{
|
|
54
52
|
shortcut?: string;
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
newName?: string;
|
|
54
|
+
}> & (StringOptionSpecification | NumberOptionSpecification | BooleanParameterSpecification | JSON5_ParameterSpecification);
|
|
55
|
+
type StringOptionSpecification = Readonly<{
|
|
57
56
|
type: ParametersTypes.string;
|
|
58
|
-
required: boolean;
|
|
59
57
|
allowedAlternatives?: ReadonlyArray<string>;
|
|
60
|
-
|
|
61
|
-
}>;
|
|
62
|
-
type NumberOptionSpecification = ParameterSpecification__CommonProperties & Readonly<{
|
|
63
|
-
type: ParametersTypes.number;
|
|
58
|
+
}> & (Readonly<{
|
|
64
59
|
required: boolean;
|
|
60
|
+
}> | Readonly<{
|
|
61
|
+
defaultValue: string;
|
|
62
|
+
}>);
|
|
63
|
+
type NumberOptionSpecification = Readonly<{
|
|
64
|
+
type: ParametersTypes.number;
|
|
65
65
|
numbersSet: RawObjectDataProcessor.NumbersSets;
|
|
66
66
|
minimalValue?: number;
|
|
67
67
|
maximalValue?: number;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
}> & (Readonly<{
|
|
69
|
+
required: boolean;
|
|
70
|
+
}> | Readonly<{
|
|
71
|
+
defaultValue: number;
|
|
72
|
+
}>);
|
|
73
|
+
type BooleanParameterSpecification = Readonly<{
|
|
71
74
|
type: ParametersTypes.boolean;
|
|
72
|
-
newName?: string;
|
|
73
75
|
}>;
|
|
74
|
-
type JSON5_ParameterSpecification =
|
|
76
|
+
type JSON5_ParameterSpecification = Readonly<{
|
|
75
77
|
type: ParametersTypes.JSON5;
|
|
78
|
+
validValueSpecification: RawObjectDataProcessor.PropertiesSpecification;
|
|
79
|
+
}> & (Readonly<{
|
|
76
80
|
required: boolean;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
81
|
+
}> | Readonly<{
|
|
82
|
+
defaultValue: ParsedJSON;
|
|
83
|
+
}>);
|
|
80
84
|
enum ParametersTypes {
|
|
81
85
|
string = "string",
|
|
82
86
|
number = "number",
|
|
@@ -150,6 +154,7 @@ declare namespace ConsoleCommandsParser {
|
|
|
150
154
|
shortcut: string;
|
|
151
155
|
type: string;
|
|
152
156
|
isRequired: string;
|
|
157
|
+
defaultValue: string;
|
|
153
158
|
yes: string;
|
|
154
159
|
no: string;
|
|
155
160
|
allowedAlternatives: string;
|
|
@@ -215,7 +215,11 @@ class ConsoleCommandsParser {
|
|
|
215
215
|
continue;
|
|
216
216
|
}
|
|
217
217
|
if (!hasCurrentOptionBeenSpecified) {
|
|
218
|
-
if (optionSpecification
|
|
218
|
+
if ("defaultValue" in optionSpecification) {
|
|
219
|
+
parsedOptions[optionName] = optionSpecification.defaultValue;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if ("required" in optionSpecification && optionSpecification.required) {
|
|
219
223
|
es_extensions_1.Logger.throwErrorAndLog({
|
|
220
224
|
errorInstance: new InvalidConsoleCommandError_1.default({
|
|
221
225
|
applicationName: this.applicationName,
|
|
@@ -512,7 +516,11 @@ class ConsoleCommandsParser {
|
|
|
512
516
|
});
|
|
513
517
|
}
|
|
514
518
|
const validationResult = es_extensions_1.RawObjectDataProcessor.
|
|
515
|
-
process(targetParameterParsedValue,
|
|
519
|
+
process(targetParameterParsedValue, {
|
|
520
|
+
nameForLogging: optionKeyWithLeading2NDashes,
|
|
521
|
+
subtype: es_extensions_1.RawObjectDataProcessor.ObjectSubtypes.fixedKeyAndValuePairsObject,
|
|
522
|
+
properties: optionSpecification.validValueSpecification
|
|
523
|
+
});
|
|
516
524
|
if (validationResult.rawDataIsInvalid) {
|
|
517
525
|
es_extensions_1.Logger.throwErrorAndLog({
|
|
518
526
|
errorInstance: new es_extensions_1.InvalidExternalDataError({
|
|
@@ -578,6 +586,10 @@ class ConsoleCommandsParser {
|
|
|
578
586
|
textSegments.push(`\n${indentationCoordinator.insertIndent()}◯ ${helpReferenceLocalization.isRequired}: ` +
|
|
579
587
|
`${commandOptionSpecification.required ? helpReferenceLocalization.yes : helpReferenceLocalization.no}`);
|
|
580
588
|
}
|
|
589
|
+
else if ("defaultValue" in commandOptionSpecification) {
|
|
590
|
+
textSegments.push(`\n${indentationCoordinator.insertIndent()}◯ ${helpReferenceLocalization.defaultValue}: ` +
|
|
591
|
+
`${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(commandOptionSpecification.defaultValue)}`);
|
|
592
|
+
}
|
|
581
593
|
switch (commandOptionSpecification.type) {
|
|
582
594
|
case ConsoleCommandsParser.ParametersTypes.string: {
|
|
583
595
|
if ((0, es_extensions_1.isNonEmptyArray)(commandOptionSpecification.allowedAlternatives)) {
|
|
@@ -7,17 +7,18 @@ const consoleCommandsParserLocalization__english = {
|
|
|
7
7
|
options: "Options",
|
|
8
8
|
shortcut: "Shortcut",
|
|
9
9
|
type: "Type",
|
|
10
|
-
isRequired: "Is
|
|
10
|
+
isRequired: "Is Required",
|
|
11
|
+
defaultValue: "Default Value",
|
|
11
12
|
yes: "Yes",
|
|
12
13
|
no: "No",
|
|
13
|
-
allowedAlternatives: "Allowed
|
|
14
|
+
allowedAlternatives: "Allowed Alternatives",
|
|
14
15
|
numbersSet: {
|
|
15
|
-
key: "Numbers
|
|
16
|
+
key: "Numbers Set",
|
|
16
17
|
generateValue: es_extensions_1.RawObjectDataProcessorLocalization__English.numbersSet
|
|
17
18
|
},
|
|
18
|
-
minimalValue: "Minimal
|
|
19
|
-
maximalValue: "Maximal
|
|
20
|
-
objectTypeValuePropertiesSpecification: "Properties
|
|
19
|
+
minimalValue: "Minimal Value",
|
|
20
|
+
maximalValue: "Maximal Value",
|
|
21
|
+
objectTypeValuePropertiesSpecification: "Properties Specification"
|
|
21
22
|
},
|
|
22
23
|
generateCheckTheCommandReferenceAsking: (commandReference) => `Please check the reference for this command:\n${commandReference}`,
|
|
23
24
|
errorsMessages: {
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const glob_1 = __importDefault(require("glob"));
|
|
7
|
-
const minimatch_1 =
|
|
7
|
+
const minimatch_1 = require("minimatch");
|
|
8
8
|
const es_extensions_1 = require("@yamato-daiwa/es-extensions");
|
|
9
9
|
const appendCharacterIfItDoesNotPresentInLastPosition_1 = __importDefault(require("./Temporary/appendCharacterIfItDoesNotPresentInLastPosition"));
|
|
10
10
|
class ImprovedGlob {
|
|
@@ -31,12 +31,12 @@ class ImprovedGlob {
|
|
|
31
31
|
return matchingFilesAbsolutePaths.map((fileAbsolutePath) => (0, es_extensions_1.replaceDoubleBackslashesWithForwardSlashes)(fileAbsolutePath));
|
|
32
32
|
}
|
|
33
33
|
static isFilePathMatchingWithGlobSelector(compoundParameter) {
|
|
34
|
-
return (0, minimatch_1.
|
|
34
|
+
return (0, minimatch_1.minimatch)(compoundParameter.filePath, compoundParameter.globSelector);
|
|
35
35
|
}
|
|
36
36
|
static isFilePathMatchingWithAllGlobSelectors(compoundParameter) {
|
|
37
37
|
return (Array.isArray(compoundParameter.globSelectors) ?
|
|
38
38
|
compoundParameter.globSelectors : [compoundParameter.globSelectors]).
|
|
39
|
-
every((globSelector) => (0, minimatch_1.
|
|
39
|
+
every((globSelector) => (0, minimatch_1.minimatch)(compoundParameter.filePath, globSelector));
|
|
40
40
|
}
|
|
41
41
|
static isExcludingGlobSelector(globSelector) {
|
|
42
42
|
return globSelector.startsWith("!");
|
|
@@ -36,7 +36,7 @@ declare namespace ObjectDataFilesProcessor {
|
|
|
36
36
|
}
|
|
37
37
|
type Localization = Readonly<{
|
|
38
38
|
generateUnableToDecideDataParsingAlgorithmErrorMessage: (templateVariables: Localization.UnableToDecideDataParsingAlgorithmErrorMessage.TemplateVariables) => string;
|
|
39
|
-
|
|
39
|
+
generateUnsupportedFileNameExtensionErrorMessage: (templateVariables: Localization.UnsupportedFileNameExtensionErrorMessage.TemplateVariables) => string;
|
|
40
40
|
}>;
|
|
41
41
|
namespace Localization {
|
|
42
42
|
namespace UnableToDecideDataParsingAlgorithmErrorMessage {
|
|
@@ -55,7 +55,7 @@ class ObjectDataFilesProcessor {
|
|
|
55
55
|
errorInstance: new es_extensions_1.InvalidParameterValueError({
|
|
56
56
|
parameterName: "compoundParameter.filePath",
|
|
57
57
|
parameterNumber: 1,
|
|
58
|
-
messageSpecificPart: ObjectDataFilesProcessor.localization.
|
|
58
|
+
messageSpecificPart: ObjectDataFilesProcessor.localization.generateUnsupportedFileNameExtensionErrorMessage({
|
|
59
59
|
filePath, fileNameLastExtensionWithoutLeadingDot
|
|
60
60
|
})
|
|
61
61
|
}),
|
package/Distributable/ObjectDataFilesProcessor/ObjectDataFilesProcessorLocalization.english.js
CHANGED
|
@@ -4,7 +4,7 @@ const objectDataFilesProcessorLocalization__english = {
|
|
|
4
4
|
generateUnableToDecideDataParsingAlgorithmErrorMessage: ({ filePath }) => `Unable to decide the data parsing algorithm because target file path "${filePath}" has no the file name extension. ` +
|
|
5
5
|
"If it is intentional, specify \"dataSchema\" property with desired element of " +
|
|
6
6
|
"\"ObjectDataFilesProcessor.SupportedSchemas\" enumeration.",
|
|
7
|
-
|
|
7
|
+
generateUnsupportedFileNameExtensionErrorMessage: ({ filePath, fileNameLastExtensionWithoutLeadingDot }) => `Target file "${filePath}" has unsupported file name extension "${fileNameLastExtensionWithoutLeadingDot}". ` +
|
|
8
8
|
"If it is intentional and this file including the data of known for \"ObjectDataFilesProcessor\" schema, please specify " +
|
|
9
9
|
"\"compoundParameter.dataSchema\" with desired element of \"ObjectDataFilesProcessor.SupportedSchemas\" enumeration."
|
|
10
10
|
};
|
package/Distributable/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @yamato-daiwa/es-extensions-nodejs v1.
|
|
3
|
-
* (c)
|
|
2
|
+
* @yamato-daiwa/es-extensions-nodejs v1.6
|
|
3
|
+
* (c) 2023 Yamato Daiwa Co., Ltd
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
export { default as NodeJS_Timer } from "./DateTime/NodeJS_Timer";
|
package/Distributable/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*!
|
|
3
|
-
* @yamato-daiwa/es-extensions-nodejs v1.
|
|
4
|
-
* (c)
|
|
3
|
+
* @yamato-daiwa/es-extensions-nodejs v1.6
|
|
4
|
+
* (c) 2023 Yamato Daiwa Co., Ltd
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023-present, Yamato Daiwa Co., Ltd
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -28,12 +28,9 @@ npm i @yamato-daiwa/es-extensions-nodejs @yamato-daiwa/es-extensions -E
|
|
|
28
28
|
<dt><a href="https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions/blob/master/NodeJS/Package/Documentation/Logging/ConsoleApplicationLogger/ConsoleApplicationLogger.md">ConsoleApplicationLogger</a></dt>
|
|
29
29
|
<dd>The implementation of <b>ILogger</b> interface for <a href="https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions/blob/master/CoreLibrary/Package/Documentation/Logging/Logger/Logger.md">Logger</a> facade and Node.js environment.</dd>
|
|
30
30
|
|
|
31
|
-
<dt><a href=https://ee.yamato-daiwa.com/NodeJS/ConsoleCommandsParser/ConsoleCommandsParser.english.html">ConsoleCommandsParser</a></dt>
|
|
31
|
+
<dt><a href="https://ee.yamato-daiwa.com/NodeJS/ConsoleCommandsParser/ConsoleCommandsParser.english.html">ConsoleCommandsParser</a></dt>
|
|
32
32
|
<dd>Parsing and validating of CLI commands</dd>
|
|
33
33
|
|
|
34
|
-
<dt><a href=https://ee.yamato-daiwa.com/NodeJS/ObjectDataFilesProcessor/ObjectDataFilesProcessor.english.html">ObjectDataFilesProcessor</a></dt>
|
|
35
|
-
<dd>Parses, validates and do other processings with data from ".json", ".y(a)ml" and ".env" files.</dd>
|
|
36
|
-
|
|
37
34
|
<dt>isErrnoException</dt>
|
|
38
35
|
<dd>Type guard which checks is value compatible with <b>NodeJS.ErrnoException</b> interface.</dd>
|
|
39
36
|
|
|
@@ -44,13 +41,10 @@ npm i @yamato-daiwa/es-extensions-nodejs @yamato-daiwa/es-extensions -E
|
|
|
44
41
|
|
|
45
42
|
<dl>
|
|
46
43
|
|
|
47
|
-
<dt
|
|
48
|
-
<dd>Intended to be thrown when the path must refer to the file, while actually refers to the directory.</dd>
|
|
49
|
-
|
|
50
|
-
<dt><a href=https://ee.yamato-daiwa.com/NodeJS/ErrorsClasses/FileNotFoundError/FileNotFoundError.english.html">FileNotFoundError</a></dt>
|
|
44
|
+
<dt>FileNotFoundError</dt>
|
|
51
45
|
<dd>Intended to be thrown when the file which expected to exist was not found.</dd>
|
|
52
46
|
|
|
53
|
-
<dt
|
|
47
|
+
<dt>InvalidConsoleCommandError</dt>
|
|
54
48
|
<dd>Intended to be thrown when the inputted console commands does not match with the manual.</dd>
|
|
55
49
|
|
|
56
50
|
</dl>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamato-daiwa/es-extensions-nodejs",
|
|
3
|
-
"version": "1.6.0
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Additional to @yamato-daiwa/es-extensions functionality for Node.js environment. Helper functions and classes aimed to reduce the routine code. Build-in TypeScript type safety.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nodejs",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"email": "tokugawa.takesi@gmail.com"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
16
|
+
"homepage": "https://ee.yamato-daiwa.com",
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
18
19
|
"url": "https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions.git"
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"yamljs": "0.3.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@yamato-daiwa/es-extensions": "
|
|
38
|
+
"@yamato-daiwa/es-extensions": "^1.6.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/json5": "0.0.30",
|