@rushstack/localization-utilities 0.11.0 → 0.12.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/CHANGELOG.json +32 -0
- package/CHANGELOG.md +16 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/TypingsGenerator.d.ts.map +1 -1
- package/lib/TypingsGenerator.js +16 -11
- package/lib/TypingsGenerator.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/localization-utilities",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.12.0",
|
|
6
|
+
"tag": "@rushstack/localization-utilities_v0.12.0",
|
|
7
|
+
"date": "Mon, 26 Aug 2024 02:00:11 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add a `valueDocumentationComment` option to `exportAsDefault` that allows a documentation comment to be generated for the exported value."
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "Rename the `documentationComment` property in the `exportAsDefault` value to `interfaceDocumentationComment`."
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"dependency": [
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/typings-generator\" to `0.14.0`"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"version": "0.11.1",
|
|
26
|
+
"tag": "@rushstack/localization-utilities_v0.11.1",
|
|
27
|
+
"date": "Wed, 21 Aug 2024 16:24:51 GMT",
|
|
28
|
+
"comments": {
|
|
29
|
+
"patch": [
|
|
30
|
+
{
|
|
31
|
+
"comment": "Fix an issue where `inferDefaultExportInterfaceNameFromFilename` did not apply."
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
4
36
|
{
|
|
5
37
|
"version": "0.11.0",
|
|
6
38
|
"tag": "@rushstack/localization-utilities_v0.11.0",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Change Log - @rushstack/localization-utilities
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 26 Aug 2024 02:00:11 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.12.0
|
|
6
|
+
Mon, 26 Aug 2024 02:00:11 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Add a `valueDocumentationComment` option to `exportAsDefault` that allows a documentation comment to be generated for the exported value.
|
|
11
|
+
- Rename the `documentationComment` property in the `exportAsDefault` value to `interfaceDocumentationComment`.
|
|
12
|
+
|
|
13
|
+
## 0.11.1
|
|
14
|
+
Wed, 21 Aug 2024 16:24:51 GMT
|
|
15
|
+
|
|
16
|
+
### Patches
|
|
17
|
+
|
|
18
|
+
- Fix an issue where `inferDefaultExportInterfaceNameFromFilename` did not apply.
|
|
4
19
|
|
|
5
20
|
## 0.11.0
|
|
6
21
|
Wed, 21 Aug 2024 05:43:04 GMT
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingsGenerator.d.ts","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,4BAA4B,
|
|
1
|
+
{"version":3,"file":"TypingsGenerator.d.ts","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,4BAA4B,EAE5B,KAAK,uBAAuB,EAE5B,KAAK,4BAA4B,EAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,oBAAoB,EAAqB,MAAM,cAAc,CAAC;AAG5E;;GAEG;AACH,MAAM,WAAW,yCACf,SAAQ,IAAI,CAAC,uBAAuB,EAAE,eAAe,CAAC;IACtD;;;OAGG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,4BAA4B;IAC5E,eAAe,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,yCAAyC,CAAC;IAEhG,wBAAwB,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAEnD,yBAAyB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAEhD,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAEpC,cAAc,CAAC,EAAE,CACf,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,KACf,MAAM,GAAG,SAAS,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,4BAA4B;gBAC7C,OAAO,EAAE,wBAAwB;CA0ErD"}
|
package/lib/TypingsGenerator.js
CHANGED
|
@@ -30,8 +30,8 @@ class TypingsGenerator extends typings_generator_1.StringValuesTypingsGenerator
|
|
|
30
30
|
});
|
|
31
31
|
const typings = [];
|
|
32
32
|
// eslint-disable-next-line guard-for-in
|
|
33
|
-
for (const stringName
|
|
34
|
-
let comment =
|
|
33
|
+
for (const [stringName, value] of Object.entries(locFileData)) {
|
|
34
|
+
let comment = value.comment;
|
|
35
35
|
if (processComment) {
|
|
36
36
|
comment = processComment(comment, relativeFilePath, stringName);
|
|
37
37
|
}
|
|
@@ -40,7 +40,6 @@ class TypingsGenerator extends typings_generator_1.StringValuesTypingsGenerator
|
|
|
40
40
|
comment
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
let exportAsDefaultInterfaceName;
|
|
44
43
|
if (inferDefaultExportInterfaceNameFromFilename) {
|
|
45
44
|
const lastSlashIndex = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\'));
|
|
46
45
|
let extensionIndex = filePath.lastIndexOf('.');
|
|
@@ -50,16 +49,22 @@ class TypingsGenerator extends typings_generator_1.StringValuesTypingsGenerator
|
|
|
50
49
|
const fileNameWithoutExtension = filePath.substring(lastSlashIndex + 1, extensionIndex);
|
|
51
50
|
const normalizedFileName = fileNameWithoutExtension.replace(/[^a-zA-Z0-9$_]/g, '');
|
|
52
51
|
const firstCharUpperCased = normalizedFileName.charAt(0).toUpperCase();
|
|
53
|
-
|
|
54
|
-
if (!
|
|
55
|
-
|
|
56
|
-
exportAsDefaultInterfaceName += 'Strings';
|
|
52
|
+
let interfaceName = `I${firstCharUpperCased}${normalizedFileName.slice(1)}`;
|
|
53
|
+
if (!interfaceName.endsWith('strings') && !interfaceName.endsWith('Strings')) {
|
|
54
|
+
interfaceName += 'Strings';
|
|
57
55
|
}
|
|
56
|
+
return {
|
|
57
|
+
typings,
|
|
58
|
+
exportAsDefault: {
|
|
59
|
+
interfaceName
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return {
|
|
65
|
+
typings
|
|
66
|
+
};
|
|
58
67
|
}
|
|
59
|
-
return {
|
|
60
|
-
typings,
|
|
61
|
-
exportAsDefaultInterfaceName
|
|
62
|
-
};
|
|
63
68
|
}
|
|
64
69
|
});
|
|
65
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,
|
|
1
|
+
{"version":3,"file":"TypingsGenerator.js","sourceRoot":"","sources":["../src/TypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAMsC;AAItC,mDAA+C;AAiC/C;;;;GAIG;AACH,MAAa,gBAAiB,SAAQ,gDAA4B;IAChE,YAAmB,OAAiC;QAClD,MAAM,EACJ,YAAY,EACZ,cAAc,E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AC,KAAK,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;wBAC7D,cAAc,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC;oBACjE,CAAC;oBAED,MAAM,wBAAwB,GAAW,QAAQ,CAAC,SAAS,CAAC,cAAc,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;oBAChG,MAAM,kBAAkB,GAAW,wBAAwB,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;oBAC3F,MAAM,mBAAmB,GAAW,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;oBAC/E,IAAI,aAAa,GAAuB,IAAI,mBAAmB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;oBAEhG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;wBAC7E,aAAa,IAAI,SAAS,CAAC;oBAC7B,CAAC;oBAED,OAAO;wBACL,OAAO;wBACP,eAAe,EAAE;4BACf,aAAa;yBACd;qBACF,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,OAAO;wBACL,OAAO;qBACR,CAAC;gBACJ,CAAC;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AA3ED,4CA2EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport {\n StringValuesTypingsGenerator,\n type IStringValueTypings,\n type IExportAsDefaultOptions,\n type IStringValueTyping,\n type ITypingsGeneratorBaseOptions\n} from '@rushstack/typings-generator';\nimport type { NewlineKind } from '@rushstack/node-core-library';\n\nimport type { IgnoreStringFunction, ILocalizationFile } from './interfaces';\nimport { parseLocFile } from './LocFileParser';\n\n/**\n * @public\n */\nexport interface IInferInterfaceNameExportAsDefaultOptions\n extends Omit<IExportAsDefaultOptions, 'interfaceName'> {\n /**\n * When `exportAsDefault` is true and this option is true, the default export interface name will be inferred\n * from the filename.\n */\n inferInterfaceNameFromFilename?: boolean;\n}\n\n/**\n * @public\n */\nexport interface ITypingsGeneratorOptions extends ITypingsGeneratorBaseOptions {\n exportAsDefault?: boolean | IExportAsDefaultOptions | IInferInterfaceNameExportAsDefaultOptions;\n\n resxNewlineNormalization?: NewlineKind | undefined;\n\n ignoreMissingResxComments?: boolean | undefined;\n\n ignoreString?: IgnoreStringFunction;\n\n processComment?: (\n comment: string | undefined,\n relativeFilePath: string,\n stringName: string\n ) => string | undefined;\n}\n\n/**\n * This is a simple tool that generates .d.ts files for .loc.json, .resx.json, .resjson, and .resx files.\n *\n * @public\n */\nexport class TypingsGenerator extends StringValuesTypingsGenerator {\n public constructor(options: ITypingsGeneratorOptions) {\n const {\n ignoreString,\n processComment,\n resxNewlineNormalization,\n ignoreMissingResxComments,\n exportAsDefault\n } = options;\n const inferDefaultExportInterfaceNameFromFilename: boolean | undefined =\n typeof exportAsDefault === 'object'\n ? (exportAsDefault as IInferInterfaceNameExportAsDefaultOptions).inferInterfaceNameFromFilename\n : undefined;\n super({\n ...options,\n fileExtensions: ['.resx', '.resx.json', '.loc.json', '.resjson'],\n parseAndGenerateTypings: (\n content: string,\n filePath: string,\n relativeFilePath: string\n ): IStringValueTypings => {\n const locFileData: ILocalizationFile = parseLocFile({\n filePath,\n content,\n terminal: this.terminal,\n resxNewlineNormalization,\n ignoreMissingResxComments,\n ignoreString\n });\n\n const typings: IStringValueTyping[] = [];\n\n // eslint-disable-next-line guard-for-in\n for (const [stringName, value] of Object.entries(locFileData)) {\n let comment: string | undefined = value.comment;\n if (processComment) {\n comment = processComment(comment, relativeFilePath, stringName);\n }\n\n typings.push({\n exportName: stringName,\n comment\n });\n }\n\n if (inferDefaultExportInterfaceNameFromFilename) {\n const lastSlashIndex: number = Math.max(filePath.lastIndexOf('/'), filePath.lastIndexOf('\\\\'));\n let extensionIndex: number = filePath.lastIndexOf('.');\n if (filePath.slice(extensionIndex).toLowerCase() === '.json') {\n extensionIndex = filePath.lastIndexOf('.', extensionIndex - 1);\n }\n\n const fileNameWithoutExtension: string = filePath.substring(lastSlashIndex + 1, extensionIndex);\n const normalizedFileName: string = fileNameWithoutExtension.replace(/[^a-zA-Z0-9$_]/g, '');\n const firstCharUpperCased: string = normalizedFileName.charAt(0).toUpperCase();\n let interfaceName: string | undefined = `I${firstCharUpperCased}${normalizedFileName.slice(1)}`;\n\n if (!interfaceName.endsWith('strings') && !interfaceName.endsWith('Strings')) {\n interfaceName += 'Strings';\n }\n\n return {\n typings,\n exportAsDefault: {\n interfaceName\n }\n };\n } else {\n return {\n typings\n };\n }\n }\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/localization-utilities",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "This plugin contains some useful functions for localization.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "dist/localization-utilities.d.ts",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"xmldoc": "~1.1.2",
|
|
16
16
|
"@rushstack/node-core-library": "5.7.0",
|
|
17
17
|
"@rushstack/terminal": "0.14.0",
|
|
18
|
-
"@rushstack/typings-generator": "0.
|
|
18
|
+
"@rushstack/typings-generator": "0.14.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/xmldoc": "1.1.4",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"local-node-rig": "1.0.0",
|
|
23
|
+
"@rushstack/heft": "0.67.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "heft build --clean",
|