@rushstack/typings-generator 0.13.0 → 0.14.1

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,39 @@
1
1
  {
2
2
  "name": "@rushstack/typings-generator",
3
3
  "entries": [
4
+ {
5
+ "version": "0.14.1",
6
+ "tag": "@rushstack/typings-generator_v0.14.1",
7
+ "date": "Tue, 10 Sep 2024 20:08:11 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.8.0`"
12
+ },
13
+ {
14
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.14.1`"
15
+ },
16
+ {
17
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.67.1`"
18
+ }
19
+ ]
20
+ }
21
+ },
22
+ {
23
+ "version": "0.14.0",
24
+ "tag": "@rushstack/typings-generator_v0.14.0",
25
+ "date": "Mon, 26 Aug 2024 02:00:11 GMT",
26
+ "comments": {
27
+ "minor": [
28
+ {
29
+ "comment": "Add a `valueDocumentationComment` option to `exportAsDefault` that allows a documentation comment to be generated for the exported value."
30
+ },
31
+ {
32
+ "comment": "Rename the `documentationComment` property in the `exportAsDefault` value to `interfaceDocumentationComment`."
33
+ }
34
+ ]
35
+ }
36
+ },
4
37
  {
5
38
  "version": "0.13.0",
6
39
  "tag": "@rushstack/typings-generator_v0.13.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Change Log - @rushstack/typings-generator
2
2
 
3
- This log was last generated on Wed, 21 Aug 2024 05:43:04 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 10 Sep 2024 20:08:11 GMT and should not be manually modified.
4
+
5
+ ## 0.14.1
6
+ Tue, 10 Sep 2024 20:08:11 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 0.14.0
11
+ Mon, 26 Aug 2024 02:00:11 GMT
12
+
13
+ ### Minor changes
14
+
15
+ - Add a `valueDocumentationComment` option to `exportAsDefault` that allows a documentation comment to be generated for the exported value.
16
+ - Rename the `documentationComment` property in the `exportAsDefault` value to `interfaceDocumentationComment`.
4
17
 
5
18
  ## 0.13.0
6
19
  Wed, 21 Aug 2024 05:43:04 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.6"
8
+ "packageVersion": "7.47.7"
9
9
  }
10
10
  ]
11
11
  }
@@ -18,11 +18,20 @@ export declare interface IExportAsDefaultOptions {
18
18
  * @defaultValue "IExport"
19
19
  */
20
20
  interfaceName?: string;
21
+ /**
22
+ * @deprecated - Use {@link IExportAsDefaultOptions.interfaceDocumentationComment} instead.
23
+ */
24
+ documentationComment?: string;
21
25
  /**
22
26
  * This value is placed in a documentation comment for the
23
27
  * exported default interface.
24
28
  */
25
- documentationComment?: string;
29
+ interfaceDocumentationComment?: string;
30
+ /**
31
+ * This value is placed in a documentation comment for the
32
+ * exported const value.
33
+ */
34
+ valueDocumentationComment?: string;
26
35
  }
27
36
 
28
37
  /**
@@ -27,11 +27,20 @@ export interface IExportAsDefaultOptions {
27
27
  * @defaultValue "IExport"
28
28
  */
29
29
  interfaceName?: string;
30
+ /**
31
+ * @deprecated - Use {@link IExportAsDefaultOptions.interfaceDocumentationComment} instead.
32
+ */
33
+ documentationComment?: string;
30
34
  /**
31
35
  * This value is placed in a documentation comment for the
32
36
  * exported default interface.
33
37
  */
34
- documentationComment?: string;
38
+ interfaceDocumentationComment?: string;
39
+ /**
40
+ * This value is placed in a documentation comment for the
41
+ * exported const value.
42
+ */
43
+ valueDocumentationComment?: string;
35
44
  }
36
45
  /**
37
46
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"StringValuesTypingsGenerator.d.ts","sourceRoot":"","sources":["../src/StringValuesTypingsGenerator.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,wBAAwB,EAC7B,gBAAgB,EAChB,KAAK,0CA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oCAAoC,CAAC,aAAa,CAAC,GAAG,KAAK;gBAElF,OAAO,EAAE,sDAAsD,CAAC,aAAa,CAAC;CAIlG"}
@@ -8,21 +8,24 @@ const node_core_library_1 = require("@rushstack/node-core-library");
8
8
  const TypingsGenerator_1 = require("./TypingsGenerator");
9
9
  const EXPORT_AS_DEFAULT_INTERFACE_NAME = 'IExport';
10
10
  function convertToTypingsGeneratorOptions(options) {
11
- var _a, _b;
11
+ var _a;
12
12
  const { exportAsDefault: exportAsDefaultOptions, exportAsDefaultInterfaceName: exportAsDefaultInterfaceName_deprecated, parseAndGenerateTypings } = options;
13
- let defaultSplitExportAsDefaultDocumentationComment;
13
+ let defaultSplitExportAsDefaultInterfaceDocumentationComment;
14
+ let defaultSplitExportAsDefaultValueDocumentationComment;
14
15
  let defaultExportAsDefaultInterfaceName;
15
16
  if (typeof exportAsDefaultOptions === 'object') {
16
- defaultSplitExportAsDefaultDocumentationComment = node_core_library_1.Text.splitByNewLines(exportAsDefaultOptions.documentationComment);
17
+ const { interfaceDocumentationComment, documentationComment: interfaceDocumentationComment_deprecated, valueDocumentationComment, interfaceName } = exportAsDefaultOptions;
18
+ defaultSplitExportAsDefaultInterfaceDocumentationComment = node_core_library_1.Text.splitByNewLines(interfaceDocumentationComment !== null && interfaceDocumentationComment !== void 0 ? interfaceDocumentationComment : interfaceDocumentationComment_deprecated);
19
+ defaultSplitExportAsDefaultValueDocumentationComment = node_core_library_1.Text.splitByNewLines(valueDocumentationComment);
17
20
  defaultExportAsDefaultInterfaceName =
18
- (_b = (_a = exportAsDefaultOptions.interfaceName) !== null && _a !== void 0 ? _a : exportAsDefaultInterfaceName_deprecated) !== null && _b !== void 0 ? _b : EXPORT_AS_DEFAULT_INTERFACE_NAME;
21
+ (_a = interfaceName !== null && interfaceName !== void 0 ? interfaceName : exportAsDefaultInterfaceName_deprecated) !== null && _a !== void 0 ? _a : EXPORT_AS_DEFAULT_INTERFACE_NAME;
19
22
  }
20
23
  else if (exportAsDefaultOptions) {
21
24
  defaultExportAsDefaultInterfaceName =
22
25
  exportAsDefaultInterfaceName_deprecated !== null && exportAsDefaultInterfaceName_deprecated !== void 0 ? exportAsDefaultInterfaceName_deprecated : EXPORT_AS_DEFAULT_INTERFACE_NAME;
23
26
  }
24
27
  async function parseAndGenerateTypingsOuter(fileContents, filePath, relativePath) {
25
- var _a, _b;
28
+ var _a, _b, _c, _d;
26
29
  const stringValueTypings = await parseAndGenerateTypings(fileContents, filePath, relativePath);
27
30
  if (stringValueTypings === undefined) {
28
31
  return;
@@ -30,23 +33,28 @@ function convertToTypingsGeneratorOptions(options) {
30
33
  const { exportAsDefault: exportAsDefaultOptionsOverride, typings } = stringValueTypings;
31
34
  let exportAsDefaultInterfaceName;
32
35
  let interfaceDocumentationCommentLines;
36
+ let valueDocumentationCommentLines;
33
37
  if (typeof exportAsDefaultOptionsOverride === 'boolean') {
34
38
  if (exportAsDefaultOptionsOverride) {
35
39
  exportAsDefaultInterfaceName =
36
40
  defaultExportAsDefaultInterfaceName !== null && defaultExportAsDefaultInterfaceName !== void 0 ? defaultExportAsDefaultInterfaceName : EXPORT_AS_DEFAULT_INTERFACE_NAME;
37
- interfaceDocumentationCommentLines = defaultSplitExportAsDefaultDocumentationComment;
41
+ interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;
42
+ valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;
38
43
  }
39
44
  }
40
45
  else if (exportAsDefaultOptionsOverride) {
41
- const { interfaceName, documentationComment } = exportAsDefaultOptionsOverride;
46
+ const { interfaceName, documentationComment, interfaceDocumentationComment, valueDocumentationComment } = exportAsDefaultOptionsOverride;
42
47
  exportAsDefaultInterfaceName =
43
48
  (_a = interfaceName !== null && interfaceName !== void 0 ? interfaceName : defaultExportAsDefaultInterfaceName) !== null && _a !== void 0 ? _a : EXPORT_AS_DEFAULT_INTERFACE_NAME;
44
49
  interfaceDocumentationCommentLines =
45
- (_b = node_core_library_1.Text.splitByNewLines(documentationComment)) !== null && _b !== void 0 ? _b : defaultSplitExportAsDefaultDocumentationComment;
50
+ (_c = (_b = node_core_library_1.Text.splitByNewLines(interfaceDocumentationComment)) !== null && _b !== void 0 ? _b : node_core_library_1.Text.splitByNewLines(documentationComment)) !== null && _c !== void 0 ? _c : defaultSplitExportAsDefaultInterfaceDocumentationComment;
51
+ valueDocumentationCommentLines =
52
+ (_d = node_core_library_1.Text.splitByNewLines(valueDocumentationComment)) !== null && _d !== void 0 ? _d : defaultSplitExportAsDefaultValueDocumentationComment;
46
53
  }
47
54
  else {
48
55
  exportAsDefaultInterfaceName = defaultExportAsDefaultInterfaceName;
49
- interfaceDocumentationCommentLines = defaultSplitExportAsDefaultDocumentationComment;
56
+ interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;
57
+ valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;
50
58
  }
51
59
  const outputLines = [];
52
60
  let indent = '';
@@ -74,7 +82,15 @@ function convertToTypingsGeneratorOptions(options) {
74
82
  }
75
83
  }
76
84
  if (exportAsDefaultInterfaceName) {
77
- outputLines.push('}', '', `declare const strings: ${exportAsDefaultInterfaceName};`, '', 'export default strings;');
85
+ outputLines.push('}', '');
86
+ if (valueDocumentationCommentLines) {
87
+ outputLines.push(`/**`);
88
+ for (const line of valueDocumentationCommentLines) {
89
+ outputLines.push(` * ${line}`);
90
+ }
91
+ outputLines.push(` */`);
92
+ }
93
+ outputLines.push(`declare const strings: ${exportAsDefaultInterfaceName};`, '', 'export default strings;');
78
94
  }
79
95
  return outputLines.join(os_1.EOL);
80
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StringValuesTypingsGenerator.js","sourceRoot":"","sources":["../src/StringValuesTypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2BAAyB;AACzB,oEAAoD;AAEpD,yDAI4B;AA2E5B,MAAM,gCAAgC,GAAW,SAAS,CAAC;AAE3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EAAE,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,IAAI,CAAC,wBAAwB,UAAU,WAAW,EAAE,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,IAAI,4BAA4B,EAAE,CAAC;YACjC,WAAW,CAAC,IAAI,CACd,GAAG,EACH,EAAE,EACF,0BAA0B,4BAA4B,GAAG,EACzD,EAAE,EACF,yBAAyB,CAC1B,CAAC;QACJ,CAAC;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,QAAG,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,gBAAgB,mCACjB,OAAO,KACV,uBAAuB,EAAE,4BAA4B,GACtD,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAa,4BAAqD,SAAQ,mCAA+B;IAKvG,YAAmB,OAA8E;QAC/F,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AARD,oEAQC","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 { EOL } from 'os';\nimport { Text } from '@rushstack/node-core-library';\n\nimport {\n type ITypingsGeneratorOptions,\n TypingsGenerator,\n type ITypingsGeneratorOptionsWithCustomReadFile\n} from './TypingsGenerator';\n\n/**\n * @public\n */\nexport interface IStringValueTyping {\n exportName: string;\n comment?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValueTypings {\n typings: IStringValueTyping[];\n\n /**\n * Options for default exports. Note that options provided here will override\n * options provided in {@link IStringValuesTypingsGeneratorBaseOptions.exportAsDefault}.\n */\n exportAsDefault?: boolean | IExportAsDefaultOptions;\n}\n\n/**\n * @public\n */\nexport interface IExportAsDefaultOptions {\n /**\n * This setting overrides the the interface name for the default wrapped export.\n *\n * @defaultValue \"IExport\"\n */\n interfaceName?: string;\n\n /**\n * This value is placed in a documentation comment for the\n * exported default interface.\n */\n documentationComment?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorBaseOptions {\n /**\n * Setting this option wraps the typings export in a default property.\n */\n exportAsDefault?: boolean | IExportAsDefaultOptions;\n\n /**\n * @deprecated Use {@link IStringValuesTypingsGeneratorBaseOptions.exportAsDefault}'s\n * {@link IExportAsDefaultOptions.interfaceName} instead.\n */\n exportAsDefaultInterfaceName?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorOptions<TFileContents extends string = string>\n extends ITypingsGeneratorOptions<IStringValueTypings | undefined, TFileContents>,\n IStringValuesTypingsGeneratorBaseOptions {\n // Nothing added.\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents = string>\n extends ITypingsGeneratorOptionsWithCustomReadFile<IStringValueTypings | undefined, TFileContents>,\n IStringValuesTypingsGeneratorBaseOptions {\n // Nothing added.\n}\n\nconst EXPORT_AS_DEFAULT_INTERFACE_NAME: string = 'IExport';\n\nfunction convertToTypingsGeneratorOptions<TFileContents>(\n options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>\n): ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> {\n const {\n exportAsDefault: exportAsDefaultOptions,\n exportAsDefaultInterfaceName: exportAsDefaultInterfaceName_deprecated,\n parseAndGenerateTypings\n } = options;\n let defaultSplitExportAsDefaultDocumentationComment: string[] | undefined;\n let defaultExportAsDefaultInterfaceName: string | undefined;\n if (typeof exportAsDefaultOptions === 'object') {\n defaultSplitExportAsDefaultDocumentationComment = Text.splitByNewLines(\n exportAsDefaultOptions.documentationComment\n );\n defaultExportAsDefaultInterfaceName =\n exportAsDefaultOptions.interfaceName ??\n exportAsDefaultInterfaceName_deprecated ??\n EXPORT_AS_DEFAULT_INTERFACE_NAME;\n } else if (exportAsDefaultOptions) {\n defaultExportAsDefaultInterfaceName =\n exportAsDefaultInterfaceName_deprecated ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n }\n\n async function parseAndGenerateTypingsOuter(\n fileContents: TFileContents,\n filePath: string,\n relativePath: string\n ): Promise<string | undefined> {\n const stringValueTypings: IStringValueTypings | undefined = await parseAndGenerateTypings(\n fileContents,\n filePath,\n relativePath\n );\n\n if (stringValueTypings === undefined) {\n return;\n }\n\n const { exportAsDefault: exportAsDefaultOptionsOverride, typings } = stringValueTypings;\n let exportAsDefaultInterfaceName: string | undefined;\n let interfaceDocumentationCommentLines: string[] | undefined;\n if (typeof exportAsDefaultOptionsOverride === 'boolean') {\n if (exportAsDefaultOptionsOverride) {\n exportAsDefaultInterfaceName =\n defaultExportAsDefaultInterfaceName ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n interfaceDocumentationCommentLines = defaultSplitExportAsDefaultDocumentationComment;\n }\n } else if (exportAsDefaultOptionsOverride) {\n const { interfaceName, documentationComment } = exportAsDefaultOptionsOverride;\n exportAsDefaultInterfaceName =\n interfaceName ?? defaultExportAsDefaultInterfaceName ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n interfaceDocumentationCommentLines =\n Text.splitByNewLines(documentationComment) ?? defaultSplitExportAsDefaultDocumentationComment;\n } else {\n exportAsDefaultInterfaceName = defaultExportAsDefaultInterfaceName;\n interfaceDocumentationCommentLines = defaultSplitExportAsDefaultDocumentationComment;\n }\n\n const outputLines: string[] = [];\n let indent: string = '';\n if (exportAsDefaultInterfaceName) {\n if (interfaceDocumentationCommentLines) {\n outputLines.push(`/**`);\n for (const line of interfaceDocumentationCommentLines) {\n outputLines.push(` * ${line}`);\n }\n\n outputLines.push(` */`);\n }\n\n outputLines.push(`export interface ${exportAsDefaultInterfaceName} {`);\n indent = ' ';\n }\n\n for (const stringValueTyping of typings) {\n const { exportName, comment } = stringValueTyping;\n\n if (comment && comment.trim() !== '') {\n outputLines.push(`${indent}/**`, `${indent} * ${comment.replace(/\\*\\//g, '*\\\\/')}`, `${indent} */`);\n }\n\n if (exportAsDefaultInterfaceName) {\n outputLines.push(`${indent}'${exportName}': string;`, '');\n } else {\n outputLines.push(`export declare const ${exportName}: string;`, '');\n }\n }\n\n if (exportAsDefaultInterfaceName) {\n outputLines.push(\n '}',\n '',\n `declare const strings: ${exportAsDefaultInterfaceName};`,\n '',\n 'export default strings;'\n );\n }\n\n return outputLines.join(EOL);\n }\n\n const convertedOptions: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> = {\n ...options,\n parseAndGenerateTypings: parseAndGenerateTypingsOuter\n };\n\n return convertedOptions;\n}\n\n/**\n * This is a simple tool that generates .d.ts files for non-TS files that can be represented as\n * a simple set of named string exports.\n *\n * @public\n */\nexport class StringValuesTypingsGenerator<TFileContents = string> extends TypingsGenerator<TFileContents> {\n public constructor(\n options: TFileContents extends string ? IStringValuesTypingsGeneratorOptions<TFileContents> : never\n );\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>);\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>) {\n super(convertToTypingsGeneratorOptions(options));\n }\n}\n"]}
1
+ {"version":3,"file":"StringValuesTypingsGenerator.js","sourceRoot":"","sources":["../src/StringValuesTypingsGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2BAAyB;AACzB,oEAAoD;AAEpD,yDAI4B;AAsF5B,MAAM,gCAAgC,GAAW,SAAS,CAAC;AAE3D,SAAS,gCAAgC,CACvC,OAA8E;;IAE9E,MAAM,EACJ,eAAe,EAAE,sBAAsB,EACvC,4BAA4B,EAAE,uCAAuC,EACrE,uBAAuB,EACxB,GAAG,OAAO,CAAC;IACZ,IAAI,wDAA8E,CAAC;IACnF,IAAI,oDAA0E,CAAC;IAC/E,IAAI,mCAAuD,CAAC;IAC5D,IAAI,OAAO,sBAAsB,KAAK,QAAQ,EAAE,CAAC;QAC/C,MAAM,EACJ,6BAA6B,EAC7B,oBAAoB,EAAE,wCAAwC,EAC9D,yBAAyB,EACzB,a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M,CAAC,EAAE,EAAE,GAAG,MAAM,KAAK,CAAC,CAAC;YACtG,CAAC;YAED,IAAI,4BAA4B,EAAE,CAAC;gBACjC,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,UAAU,YAAY,EAAE,EAAE,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACN,WAAW,CAAC,IAAI,CAAC,wBAAwB,UAAU,WAAW,EAAE,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QAED,IAAI,4BAA4B,EAAE,CAAC;YACjC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAE1B,IAAI,8BAA8B,EAAE,CAAC;gBACnC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACxB,KAAK,MAAM,IAAI,IAAI,8BAA8B,EAAE,CAAC;oBAClD,WAAW,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;gBACjC,CAAC;gBAED,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,CAAC;YAED,WAAW,CAAC,IAAI,CACd,0BAA0B,4BAA4B,GAAG,EACzD,EAAE,EACF,yBAAyB,CAC1B,CAAC;QACJ,CAAC;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,QAAG,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,gBAAgB,mCACjB,OAAO,KACV,uBAAuB,EAAE,4BAA4B,GACtD,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAa,4BAAqD,SAAQ,mCAA+B;IAKvG,YAAmB,OAA8E;QAC/F,KAAK,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AARD,oEAQC","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 { EOL } from 'os';\nimport { Text } from '@rushstack/node-core-library';\n\nimport {\n type ITypingsGeneratorOptions,\n TypingsGenerator,\n type ITypingsGeneratorOptionsWithCustomReadFile\n} from './TypingsGenerator';\n\n/**\n * @public\n */\nexport interface IStringValueTyping {\n exportName: string;\n comment?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValueTypings {\n typings: IStringValueTyping[];\n\n /**\n * Options for default exports. Note that options provided here will override\n * options provided in {@link IStringValuesTypingsGeneratorBaseOptions.exportAsDefault}.\n */\n exportAsDefault?: boolean | IExportAsDefaultOptions;\n}\n\n/**\n * @public\n */\nexport interface IExportAsDefaultOptions {\n /**\n * This setting overrides the the interface name for the default wrapped export.\n *\n * @defaultValue \"IExport\"\n */\n interfaceName?: string;\n\n /**\n * @deprecated - Use {@link IExportAsDefaultOptions.interfaceDocumentationComment} instead.\n */\n documentationComment?: string;\n\n /**\n * This value is placed in a documentation comment for the\n * exported default interface.\n */\n interfaceDocumentationComment?: string;\n\n /**\n * This value is placed in a documentation comment for the\n * exported const value.\n */\n valueDocumentationComment?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorBaseOptions {\n /**\n * Setting this option wraps the typings export in a default property.\n */\n exportAsDefault?: boolean | IExportAsDefaultOptions;\n\n /**\n * @deprecated Use {@link IStringValuesTypingsGeneratorBaseOptions.exportAsDefault}'s\n * {@link IExportAsDefaultOptions.interfaceName} instead.\n */\n exportAsDefaultInterfaceName?: string;\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorOptions<TFileContents extends string = string>\n extends ITypingsGeneratorOptions<IStringValueTypings | undefined, TFileContents>,\n IStringValuesTypingsGeneratorBaseOptions {\n // Nothing added.\n}\n\n/**\n * @public\n */\nexport interface IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents = string>\n extends ITypingsGeneratorOptionsWithCustomReadFile<IStringValueTypings | undefined, TFileContents>,\n IStringValuesTypingsGeneratorBaseOptions {\n // Nothing added.\n}\n\nconst EXPORT_AS_DEFAULT_INTERFACE_NAME: string = 'IExport';\n\nfunction convertToTypingsGeneratorOptions<TFileContents>(\n options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>\n): ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> {\n const {\n exportAsDefault: exportAsDefaultOptions,\n exportAsDefaultInterfaceName: exportAsDefaultInterfaceName_deprecated,\n parseAndGenerateTypings\n } = options;\n let defaultSplitExportAsDefaultInterfaceDocumentationComment: string[] | undefined;\n let defaultSplitExportAsDefaultValueDocumentationComment: string[] | undefined;\n let defaultExportAsDefaultInterfaceName: string | undefined;\n if (typeof exportAsDefaultOptions === 'object') {\n const {\n interfaceDocumentationComment,\n documentationComment: interfaceDocumentationComment_deprecated,\n valueDocumentationComment,\n interfaceName\n } = exportAsDefaultOptions;\n defaultSplitExportAsDefaultInterfaceDocumentationComment = Text.splitByNewLines(\n interfaceDocumentationComment ?? interfaceDocumentationComment_deprecated\n );\n defaultSplitExportAsDefaultValueDocumentationComment = Text.splitByNewLines(valueDocumentationComment);\n defaultExportAsDefaultInterfaceName =\n interfaceName ?? exportAsDefaultInterfaceName_deprecated ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n } else if (exportAsDefaultOptions) {\n defaultExportAsDefaultInterfaceName =\n exportAsDefaultInterfaceName_deprecated ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n }\n\n async function parseAndGenerateTypingsOuter(\n fileContents: TFileContents,\n filePath: string,\n relativePath: string\n ): Promise<string | undefined> {\n const stringValueTypings: IStringValueTypings | undefined = await parseAndGenerateTypings(\n fileContents,\n filePath,\n relativePath\n );\n\n if (stringValueTypings === undefined) {\n return;\n }\n\n const { exportAsDefault: exportAsDefaultOptionsOverride, typings } = stringValueTypings;\n let exportAsDefaultInterfaceName: string | undefined;\n let interfaceDocumentationCommentLines: string[] | undefined;\n let valueDocumentationCommentLines: string[] | undefined;\n if (typeof exportAsDefaultOptionsOverride === 'boolean') {\n if (exportAsDefaultOptionsOverride) {\n exportAsDefaultInterfaceName =\n defaultExportAsDefaultInterfaceName ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;\n valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;\n }\n } else if (exportAsDefaultOptionsOverride) {\n const {\n interfaceName,\n documentationComment,\n interfaceDocumentationComment,\n valueDocumentationComment\n } = exportAsDefaultOptionsOverride;\n exportAsDefaultInterfaceName =\n interfaceName ?? defaultExportAsDefaultInterfaceName ?? EXPORT_AS_DEFAULT_INTERFACE_NAME;\n interfaceDocumentationCommentLines =\n Text.splitByNewLines(interfaceDocumentationComment) ??\n Text.splitByNewLines(documentationComment) ??\n defaultSplitExportAsDefaultInterfaceDocumentationComment;\n valueDocumentationCommentLines =\n Text.splitByNewLines(valueDocumentationComment) ??\n defaultSplitExportAsDefaultValueDocumentationComment;\n } else {\n exportAsDefaultInterfaceName = defaultExportAsDefaultInterfaceName;\n interfaceDocumentationCommentLines = defaultSplitExportAsDefaultInterfaceDocumentationComment;\n valueDocumentationCommentLines = defaultSplitExportAsDefaultValueDocumentationComment;\n }\n\n const outputLines: string[] = [];\n let indent: string = '';\n if (exportAsDefaultInterfaceName) {\n if (interfaceDocumentationCommentLines) {\n outputLines.push(`/**`);\n for (const line of interfaceDocumentationCommentLines) {\n outputLines.push(` * ${line}`);\n }\n\n outputLines.push(` */`);\n }\n\n outputLines.push(`export interface ${exportAsDefaultInterfaceName} {`);\n indent = ' ';\n }\n\n for (const stringValueTyping of typings) {\n const { exportName, comment } = stringValueTyping;\n\n if (comment && comment.trim() !== '') {\n outputLines.push(`${indent}/**`, `${indent} * ${comment.replace(/\\*\\//g, '*\\\\/')}`, `${indent} */`);\n }\n\n if (exportAsDefaultInterfaceName) {\n outputLines.push(`${indent}'${exportName}': string;`, '');\n } else {\n outputLines.push(`export declare const ${exportName}: string;`, '');\n }\n }\n\n if (exportAsDefaultInterfaceName) {\n outputLines.push('}', '');\n\n if (valueDocumentationCommentLines) {\n outputLines.push(`/**`);\n for (const line of valueDocumentationCommentLines) {\n outputLines.push(` * ${line}`);\n }\n\n outputLines.push(` */`);\n }\n\n outputLines.push(\n `declare const strings: ${exportAsDefaultInterfaceName};`,\n '',\n 'export default strings;'\n );\n }\n\n return outputLines.join(EOL);\n }\n\n const convertedOptions: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents> = {\n ...options,\n parseAndGenerateTypings: parseAndGenerateTypingsOuter\n };\n\n return convertedOptions;\n}\n\n/**\n * This is a simple tool that generates .d.ts files for non-TS files that can be represented as\n * a simple set of named string exports.\n *\n * @public\n */\nexport class StringValuesTypingsGenerator<TFileContents = string> extends TypingsGenerator<TFileContents> {\n public constructor(\n options: TFileContents extends string ? IStringValuesTypingsGeneratorOptions<TFileContents> : never\n );\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>);\n public constructor(options: IStringValuesTypingsGeneratorOptionsWithCustomReadFile<TFileContents>) {\n super(convertToTypingsGeneratorOptions(options));\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/typings-generator",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "description": "This library provides functionality for automatically generating typings for non-TS files.",
5
5
  "keywords": [
6
6
  "dts",
@@ -18,13 +18,13 @@
18
18
  "dependencies": {
19
19
  "chokidar": "~3.4.0",
20
20
  "fast-glob": "~3.3.1",
21
- "@rushstack/node-core-library": "5.7.0",
22
- "@rushstack/terminal": "0.14.0"
21
+ "@rushstack/node-core-library": "5.8.0",
22
+ "@rushstack/terminal": "0.14.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/glob": "7.1.1",
26
26
  "local-node-rig": "1.0.0",
27
- "@rushstack/heft": "0.67.0"
27
+ "@rushstack/heft": "0.67.1"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@types/node": "*"