@rushstack/localization-utilities 0.11.1 → 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 CHANGED
@@ -1,6 +1,26 @@
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
+ },
4
24
  {
5
25
  "version": "0.11.1",
6
26
  "tag": "@rushstack/localization-utilities_v0.11.1",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log - @rushstack/localization-utilities
2
2
 
3
- This log was last generated on Wed, 21 Aug 2024 16:24:51 GMT and should not be manually modified.
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`.
4
12
 
5
13
  ## 0.11.1
6
14
  Wed, 21 Aug 2024 16:24:51 GMT
@@ -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 in locFileData) {
34
- let comment = locFileData[stringName].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
  }
@@ -1 +1 @@
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,EACd,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EAChB,GAAG,OAAO,CAAC;QACZ,MAAM,2CAA2C,GAC/C,OAAO,eAAe,KAAK,QAAQ;YACjC,CAAC,CAAE,eAA6D,CAAC,8BAA8B;YAC/F,CAAC,CAAC,SAAS,CAAC;QAChB,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC;YAChE,uBAAuB,EAAE,CACvB,OAAe,EACf,QAAgB,EAChB,gBAAwB,EACH,EAAE;gBACvB,MAAM,WAAW,GAAsB,IAAA,4BAAY,EAAC;oBAClD,QAAQ;oBACR,OAAO;oBACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,wBAAwB;oBACxB,yBAAyB;oBACzB,YAAY;iBACb,CAAC,CAAC;gBAEH,MAAM,OAAO,GAAyB,EAAE,CAAC;gBAEzC,wCAAwC;gBACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;oBACrC,IAAI,OAAO,GAAuB,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;oBAClE,IAAI,cAAc,EAAE,CAAC;wBACnB,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,UAAU,CAAC,CAAC;oBAClE,CAAC;oBAED,OAAO,CAAC,I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,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 in locFileData) {\n let comment: string | undefined = locFileData[stringName].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"]}
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,EACd,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EAChB,GAAG,OAAO,CAAC;QACZ,MAAM,2CAA2C,GAC/C,OAAO,eAAe,KAAK,QAAQ;YACjC,CAAC,CAAE,eAA6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,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.11.1",
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,7 +15,7 @@
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.13.0"
18
+ "@rushstack/typings-generator": "0.14.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/xmldoc": "1.1.4",