@intlayer/chokidar 2.0.10 → 2.0.11

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/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2020-2021 Sébastien Vanvelthem
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and improving
59
+ the Work, but excluding communication that is conspicuously marked or
60
+ otherwise designated in writing by the copyright owner as "Not a
61
+ Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Aymeric PINEAU
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -52,38 +52,34 @@ const watch = (options) => {
52
52
  ...options
53
53
  }).on("ready", async () => {
54
54
  const dictionariesPaths = await (0, import_declaration_file_to_dictionary.buildDictionary)(files);
55
- console.info("Building TypeScript types...");
56
55
  await (0, import_dictionary_to_type.createTypes)(dictionariesPaths);
57
- console.info("TypeScript types built");
58
- console.info("Building Intlayer module augmentation...");
56
+ console.info("[intlayer] TypeScript types built");
59
57
  (0, import_dictionary_to_type.createModuleAugmentation)();
60
- console.info("Intlayer module augmentation built");
61
- console.info("Building Intlayer dictionary list...");
58
+ console.info("[intlayer] Intlayer module augmentation built");
62
59
  (0, import_createDictionaryList.createDictionaryList)();
63
- console.info("Intlayer dictionary list built");
60
+ console.info("[intlayer] Intlayer dictionary list built");
64
61
  const relativeDictionariesPath = dictionariesPaths.map(
65
62
  (dictionary) => (0, import_path.relative)(baseDir, dictionary)
66
63
  );
67
- console.info("Dictionaries:", relativeDictionariesPath);
64
+ console.info("[intlayer] Dictionaries:", relativeDictionariesPath);
68
65
  }).on("unlink", (filePath) => {
69
66
  console.info("Removed file detected: ", (0, import_path.relative)(baseDir, filePath));
70
67
  }).on("add", async (filePath) => {
71
- console.info("Additional file detected: ", (0, import_path.relative)(baseDir, filePath));
68
+ console.info(
69
+ "[intlayer] Additional file detected: ",
70
+ (0, import_path.relative)(baseDir, filePath)
71
+ );
72
72
  const dictionaries = await (0, import_declaration_file_to_dictionary.buildDictionary)(filePath);
73
- console.info("Building TypeScript types...");
74
73
  await (0, import_dictionary_to_type.createTypes)(dictionaries);
75
- console.info("TypeScript types built");
76
- console.info("Building Intlayer module augmentation...");
74
+ console.info("[intlayer] TypeScript types built");
77
75
  (0, import_dictionary_to_type.createModuleAugmentation)();
78
- console.info("Intlayer module augmentation built");
79
- console.info("Building main...");
76
+ console.info("[intlayer] Intlayer module augmentation built");
80
77
  (0, import_createDictionaryList.createDictionaryList)();
81
78
  }).on("change", async (filePath) => {
82
79
  console.info("Change detected: ", (0, import_path.relative)(baseDir, filePath));
83
80
  const dictionaries = await (0, import_declaration_file_to_dictionary.buildDictionary)(filePath);
84
- console.info("Building TypeScript types...");
85
81
  await (0, import_dictionary_to_type.createTypes)(dictionaries);
86
- console.info("TypeScript types built");
82
+ console.info("[intlayer] TypeScript types built");
87
83
  }).on("error", (error) => {
88
84
  console.error("Watcher error:", error);
89
85
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionariesPaths);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building Intlayer dictionary list...');\n createDictionaryList();\n console.info('Intlayer dictionary list built');\n\n const relativeDictionariesPath = dictionariesPaths.map((dictionary) =>\n relative(baseDir, dictionary)\n );\n\n console.info('Dictionaries:', relativeDictionariesPath);\n })\n .on('unlink', (filePath) => {\n // Process the file with the functionToRun\n console.info('Removed file detected: ', relative(baseDir, filePath));\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Additional file detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building main...');\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n })\n .on('error', (error)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Q,KAAK,wBAAwB;AAErC,YAAQ,KAAK,0CAA0C;AACvD,4DAAyB;AACzB,YAAQ,KAAK,oCAAoC;AAEjD,YAAQ,KAAK,kBAAkB;AAC/B,0DAAqB;AAAA,EACvB,CAAC,EACA,GAAG,UAAU,OAAO,aAAa;AAEhC,YAAQ,KAAK,yBAAqB,sBAAS,SAAS,QAAQ,CAAC;AAC7D,UAAM,eAAe,UAAM,uDAAgB,QAAQ;AAEnD,YAAQ,KAAK,8BAA8B;AAC3C,cAAM,uCAAY,YAAY;AAC9B,YAAQ,KAAK,wBAAwB;AAAA,EACvC,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,YAAQ,MAAM,kBAAkB,KAAK;AAAA,EACvC,CAAC;AACL;","names":["chokidar"]}
1
+ {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n await createTypes(dictionariesPaths);\n console.info('[intlayer] TypeScript types built');\n\n createModuleAugmentation();\n console.info('[intlayer] Intlayer module augmentation built');\n\n createDictionaryList();\n console.info('[intlayer] Intlayer dictionary list built');\n\n const relativeDictionariesPath = dictionariesPaths.map((dictionary) =>\n relative(baseDir, dictionary)\n );\n\n console.info('[intlayer] Dictionaries:', relativeDictionariesPath);\n })\n .on('unlink', (filePath) => {\n // Process the file with the functionToRun\n console.info('Removed file detected: ', relative(baseDir, filePath));\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info(\n '[intlayer] Additional file detected: ',\n relative(baseDir, filePath)\n );\n const dictionaries = await buildDictionary(filePath);\n\n await createTypes(dictionaries);\n console.info('[intlayer] TypeScript types built');\n\n createModuleAugmentation();\n console.info('[intlayer] Intlayer module augmentation built');\n\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n await createTypes(dictionaries);\n console.info('[intlayer] TypeScript types built');\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAAiC;AACjC,sBAA4C;AAC5C,kBAAqB;AACrB,4CAAgC;AAChC,kCAAqC;AACrC,gCAGO;AAGA,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,EAAE,QAAQ,QAAI,gCAAiB;AAAA,IACnC,SAAS;AAAA,EACX,CAAC;AAED,QAAM,EAAE,6BAA6B,QAAQ,IAAI;AAEjD,QAAM,YAAkB,kBAAK,2BAA2B;AAExD,SAAO,gBAAAA,QACJ,MAAM,6BAA6B;AAAA,IAClC,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACA,GAAG,SAAS,YAAY;AACvB,UAAM,oBAAoB,UAAM,uDAAgB,KAAK;AAErD,cAAM,uCAAY,iBAAiB;AACnC,YAAQ,KAAK,mCAAmC;AAEhD,4DAAyB;AACzB,YAAQ,KAAK,+CAA+C;AAE5D,0DAAqB;AACrB,YAAQ,KAAK,2CAA2C;AAExD,UAAM,2BAA2B,kBAAkB;AAAA,MAAI,CAAC,mBACtD,sBAAS,SAAS,UAAU;AAAA,IAC9B;AAEA,YAAQ,KAAK,4BAA4B,wBAAwB;AAAA,EACnE,CAAC,EACA,GAAG,UAAU,CAAC,aAAa;AAE1B,YAAQ,KAAK,+BAA2B,sBAAS,SAAS,QAAQ,CAAC;AAAA,EACrE,CAAC,EACA,GAAG,OAAO,OAAO,aAAa;AAE7B,YAAQ;AAAA,MACN;AAAA,UACA,sBAAS,SAAS,QAAQ;AAAA,IAC5B;AACA,UAAM,eAAe,UAAM,uDAAgB,QAAQ;AAEnD,cAAM,uCAAY,YAAY;AAC9B,YAAQ,KAAK,mCAAmC;AAEhD,4DAAyB;AACzB,YAAQ,KAAK,+CAA+C;AAE5D,0DAAqB;AAAA,EACvB,CAAC,EACA,GAAG,UAAU,OAAO,aAAa;AAEhC,YAAQ,KAAK,yBAAqB,sBAAS,SAAS,QAAQ,CAAC;AAC7D,UAAM,eAAe,UAAM,uDAAgB,QAAQ;AAEnD,cAAM,uCAAY,YAAY;AAC9B,YAAQ,KAAK,mCAAmC;AAAA,EAClD,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,YAAQ,MAAM,kBAAkB,KAAK;AAAA,EACvC,CAAC;AACL;","names":["chokidar"]}
@@ -32,6 +32,10 @@ const { content } = (0, import_config.getConfiguration)();
32
32
  const { typesDir } = content;
33
33
  const isESModule = typeof import_meta.url === "string";
34
34
  const requireFunction = isESModule ? (0, import_module.createRequire)(import_meta.url) : require;
35
+ const requireUncached = (module2) => {
36
+ delete requireFunction.cache[requireFunction.resolve(module2)];
37
+ return requireFunction(module2);
38
+ };
35
39
  const kebabCaseToCammelCase = (name) => name.split(/[\s\-_]+/).map((word, index) => {
36
40
  if (index === 0) {
37
41
  return word;
@@ -70,7 +74,7 @@ const createTypes = async (dictionariesPaths) => {
70
74
  (0, import_fs.mkdirSync)(typesDir, { recursive: true });
71
75
  }
72
76
  for (const dictionaryPath of dictionariesPaths) {
73
- const dictionary = requireFunction(dictionaryPath);
77
+ const dictionary = requireUncached(dictionaryPath);
74
78
  const dictionaryName = dictionary.id;
75
79
  const dictionaryNameCamelCase = kebabCaseToCammelCase(dictionaryName) + "Content";
76
80
  const dictionaryContentString = JSON.stringify(dictionary);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n quicktype,\n InputData,\n jsonInputForTargetLanguage,\n} from 'quicktype-core';\n\nconst { content } = getConfiguration();\nconst { typesDir } = content;\n\nconst isESModule = typeof import.meta.url === 'string';\nconst requireFunction = isESModule ? createRequire(import.meta.url) : require;\n\nconst kebabCaseToCammelCase = (name: string): string =>\n name\n .split(/[\\s\\-_]+/) // Regular expression to match space, hyphen, or underscore\n .map((word, index) => {\n if (index === 0) {\n return word; // Return the first word as is\n }\n return word.charAt(0).toUpperCase() + word.slice(1); // Capitalize the first letter of subsequent words\n })\n .join(''); // Join all the segments into one string\n\nexport const generateTypeScriptType = async (\n typeName: string,\n jsonString: string\n) => {\n const { lines } = await quicktypeJSON(typeName, jsonString);\n\n const linesString: string = lines.join('\\n');\n\n return linesString;\n};\n\nconst quicktypeJSON = async (typeName: string, jsonString: string) => {\n const jsonInput = jsonInputForTargetLanguage('typescript');\n\n // We could add multiple samples for the same desired\n // type, or many sources for other types. Here we're\n // just making one type from one piece of sample JSON.\n\n await jsonInput.addSource({\n name: typeName,\n samples: [jsonString],\n });\n\n const inputData = new InputData();\n inputData.addInput(jsonInput);\n\n return await quicktype({\n inputData,\n lang: 'typescript',\n alphabetizeProperties: true,\n rendererOptions: {\n 'just-types': 'true',\n 'explicit-unions': 'true',\n 'acronym-style': 'camel',\n 'prefer-types': 'true',\n readonly: 'false',\n },\n });\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[]\n): Promise<string[]> => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireFunction(dictionaryPath);\n const dictionaryName: string = dictionary.id;\n const dictionaryNameCamelCase: string =\n kebabCaseToCammelCase(dictionaryName) + 'Content';\n\n const dictionaryContentString: string = JSON.stringify(dictionary);\n\n const typeDefinition: string = await generateTypeScriptType(\n dictionaryNameCamelCase,\n dictionaryContentString\n );\n\n const outputPath: string = resolve(typesDir, `${dictionaryName}.d.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,oBAA8B;AAC9B,kBAAwB;AACxB,oBAAiC;AAEjC,4BAIO;AATP;AAWA,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,SAAS,IAAI;AAErB,MAAM,aAAa,OAAO,YAAY,QAAQ;AAC9C,MAAM,kBAAkB,iBAAa,6BAAc,YAAY,GAAG,IAAI;AAEtE,MAAM,wBAAwB,CAAC,SAC7B,KACG,MAAM,UAAU,EAChB,IAAI,CAAC,MAAM,UAAU;AACpB,MAAI,UAAU,GAAG;AACf,WAAO;AAAA,EACT;AACA,SAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AACpD,CAAC,EACA,KAAK,EAAE;AAEL,MAAM,yBAAyB,OACpC,UACA,eACG;AACH,QAAM,EAAE,MAAM,IAAI,MAAM,cAAc,UAAU,UAAU;AAE1D,QAAM,cAAsB,MAAM,KAAK,IAAI;AAE3C,SAAO;AACT;AAEA,MAAM,gBAAgB,OAAO,UAAkB,eAAuB;AACpE,QAAM,gBAAY,kDAA2B,YAAY;AAMzD,QAAM,UAAU,UAAU;AAAA,IACxB,MAAM;AAAA,IACN,SAAS,CAAC,UAAU;AAAA,EACtB,CAAC;AAED,QAAM,YAAY,IAAI,gCAAU;AAChC,YAAU,SAAS,SAAS;AAE5B,SAAO,UAAM,iCAAU;AAAA,IACrB;AAAA,IACA,MAAM;AAAA,IACN,uBAAuB;AAAA,IACvB,iBAAiB;AAAA,MACf,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACH;AAKO,MAAM,cAAc,OACzB,sBACsB;AACtB,QAAM,mBAA6B,CAAC;AAGpC,MAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB,6BAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACzC;AAEA,aAAW,kBAAkB,mBAAmB;AAC9C,UAAM,aAAyB,gBAAgB,cAAc;AAC7D,UAAM,iBAAyB,WAAW;AAC1C,UAAM,0BACJ,sBAAsB,cAAc,IAAI;AAE1C,UAAM,0BAAkC,KAAK,UAAU,UAAU;AAEjE,UAAM,iBAAyB,MAAM;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,iBAAqB,qBAAQ,UAAU,GAAG,cAAc,OAAO;AAErE,iCAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n quicktype,\n InputData,\n jsonInputForTargetLanguage,\n} from 'quicktype-core';\n\nconst { content } = getConfiguration();\nconst { typesDir } = content;\n\nconst isESModule = typeof import.meta.url === 'string';\nconst requireFunction = isESModule ? createRequire(import.meta.url) : require;\n\nconst requireUncached = (module: string) => {\n delete requireFunction.cache[requireFunction.resolve(module)];\n return requireFunction(module);\n};\n\nconst kebabCaseToCammelCase = (name: string): string =>\n name\n .split(/[\\s\\-_]+/) // Regular expression to match space, hyphen, or underscore\n .map((word, index) => {\n if (index === 0) {\n return word; // Return the first word as is\n }\n return word.charAt(0).toUpperCase() + word.slice(1); // Capitalize the first letter of subsequent words\n })\n .join(''); // Join all the segments into one string\n\nexport const generateTypeScriptType = async (\n typeName: string,\n jsonString: string\n) => {\n const { lines } = await quicktypeJSON(typeName, jsonString);\n\n const linesString: string = lines.join('\\n');\n\n return linesString;\n};\n\nconst quicktypeJSON = async (typeName: string, jsonString: string) => {\n const jsonInput = jsonInputForTargetLanguage('typescript');\n\n // We could add multiple samples for the same desired\n // type, or many sources for other types. Here we're\n // just making one type from one piece of sample JSON.\n\n await jsonInput.addSource({\n name: typeName,\n samples: [jsonString],\n });\n\n const inputData = new InputData();\n inputData.addInput(jsonInput);\n\n return await quicktype({\n inputData,\n lang: 'typescript',\n alphabetizeProperties: true,\n rendererOptions: {\n 'just-types': 'true',\n 'explicit-unions': 'true',\n 'acronym-style': 'camel',\n 'prefer-types': 'true',\n readonly: 'false',\n },\n });\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[]\n): Promise<string[]> => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireUncached(dictionaryPath);\n const dictionaryName: string = dictionary.id;\n const dictionaryNameCamelCase: string =\n kebabCaseToCammelCase(dictionaryName) + 'Content';\n\n const dictionaryContentString: string = JSON.stringify(dictionary);\n\n const typeDefinition: string = await generateTypeScriptType(\n dictionaryNameCamelCase,\n dictionaryContentString\n );\n\n const outputPath: string = resolve(typesDir, `${diction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BAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,UAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACH;AAKO,MAAM,cAAc,OACzB,sBACsB;AACtB,QAAM,mBAA6B,CAAC;AAGpC,MAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB,6BAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACzC;AAEA,aAAW,kBAAkB,mBAAmB;AAC9C,UAAM,aAAyB,gBAAgB,cAAc;AAC7D,UAAM,iBAAyB,WAAW;AAC1C,UAAM,0BACJ,sBAAsB,cAAc,IAAI;AAE1C,UAAM,0BAAkC,KAAK,UAAU,UAAU;AAEjE,UAAM,iBAAyB,MAAM;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,iBAAqB,qBAAQ,UAAU,GAAG,cAAc,OAAO;AAErE,iCAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":["module"]}
@@ -22,38 +22,34 @@ const watch = (options) => {
22
22
  ...options
23
23
  }).on("ready", async () => {
24
24
  const dictionariesPaths = await buildDictionary(files);
25
- console.info("Building TypeScript types...");
26
25
  await createTypes(dictionariesPaths);
27
- console.info("TypeScript types built");
28
- console.info("Building Intlayer module augmentation...");
26
+ console.info("[intlayer] TypeScript types built");
29
27
  createModuleAugmentation();
30
- console.info("Intlayer module augmentation built");
31
- console.info("Building Intlayer dictionary list...");
28
+ console.info("[intlayer] Intlayer module augmentation built");
32
29
  createDictionaryList();
33
- console.info("Intlayer dictionary list built");
30
+ console.info("[intlayer] Intlayer dictionary list built");
34
31
  const relativeDictionariesPath = dictionariesPaths.map(
35
32
  (dictionary) => relative(baseDir, dictionary)
36
33
  );
37
- console.info("Dictionaries:", relativeDictionariesPath);
34
+ console.info("[intlayer] Dictionaries:", relativeDictionariesPath);
38
35
  }).on("unlink", (filePath) => {
39
36
  console.info("Removed file detected: ", relative(baseDir, filePath));
40
37
  }).on("add", async (filePath) => {
41
- console.info("Additional file detected: ", relative(baseDir, filePath));
38
+ console.info(
39
+ "[intlayer] Additional file detected: ",
40
+ relative(baseDir, filePath)
41
+ );
42
42
  const dictionaries = await buildDictionary(filePath);
43
- console.info("Building TypeScript types...");
44
43
  await createTypes(dictionaries);
45
- console.info("TypeScript types built");
46
- console.info("Building Intlayer module augmentation...");
44
+ console.info("[intlayer] TypeScript types built");
47
45
  createModuleAugmentation();
48
- console.info("Intlayer module augmentation built");
49
- console.info("Building main...");
46
+ console.info("[intlayer] Intlayer module augmentation built");
50
47
  createDictionaryList();
51
48
  }).on("change", async (filePath) => {
52
49
  console.info("Change detected: ", relative(baseDir, filePath));
53
50
  const dictionaries = await buildDictionary(filePath);
54
- console.info("Building TypeScript types...");
55
51
  await createTypes(dictionaries);
56
- console.info("TypeScript types built");
52
+ console.info("[intlayer] TypeScript types built");
57
53
  }).on("error", (error) => {
58
54
  console.error("Watcher error:", error);
59
55
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionariesPaths);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building Intlayer dictionary list...');\n createDictionaryList();\n console.info('Intlayer dictionary list built');\n\n const relativeDictionariesPath = dictionariesPaths.map((dictionary) =>\n relative(baseDir, dictionary)\n );\n\n console.info('Dictionaries:', relativeDictionariesPath);\n })\n .on('unlink', (filePath) => {\n // Process the file with the functionToRun\n console.info('Removed file detected: ', relative(baseDir, filePath));\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Additional file detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n\n console.info('Building Intlayer module augmentation...');\n createModuleAugmentation();\n console.info('Intlayer module augmentation built');\n\n console.info('Building main...');\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n console.info('Building TypeScript types...');\n await createTypes(dictionaries);\n console.info('TypeScript types built');\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,OAAO,cAAqC;AAC5C,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAGA,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AAAA,IACnC,SAAS;AAAA,EACX,CAAC;AAED,QAAM,EAAE,6BAA6B,QAAQ,IAAI;AAEjD,QAAM,QAAkB,KAAK,2BAA2B;AAExD,SAAO,SACJ,MAAM,6BAA6B;AAAA,IAClC,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACA,GAAG,SAAS,YAAY;AACvB,UA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'@intlayer/config';\nimport chokidar, { type WatchOptions } from 'chokidar';\nimport { sync } from 'glob';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryList } from '../transpiler/dictionary_to_main/createDictionaryList';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const { content } = getConfiguration({\n verbose: true,\n });\n\n const { watchedFilesPatternWithPath, baseDir } = content;\n\n const files: string[] = sync(watchedFilesPatternWithPath);\n\n return chokidar\n .watch(watchedFilesPatternWithPath, {\n persistent: true, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on('ready', async () => {\n const dictionariesPaths = await buildDictionary(files);\n\n await createTypes(dictionariesPaths);\n console.info('[intlayer] TypeScript types built');\n\n createModuleAugmentation();\n console.info('[intlayer] Intlayer module augmentation built');\n\n createDictionaryList();\n console.info('[intlayer] Intlayer dictionary list built');\n\n const relativeDictionariesPath = dictionariesPaths.map((dictionary) =>\n relative(baseDir, dictionary)\n );\n\n console.info('[intlayer] Dictionaries:', relativeDictionariesPath);\n })\n .on('unlink', (filePath) => {\n // Process the file with the functionToRun\n console.info('Removed file detected: ', relative(baseDir, filePath));\n })\n .on('add', async (filePath) => {\n // Process the file with the functionToRun\n console.info(\n '[intlayer] Additional file detected: ',\n relative(baseDir, filePath)\n );\n const dictionaries = await buildDictionary(filePath);\n\n await createTypes(dictionaries);\n console.info('[intlayer] TypeScript types built');\n\n createModuleAugmentation();\n console.info('[intlayer] Intlayer module augmentation built');\n\n createDictionaryList();\n })\n .on('change', async (filePath) => {\n // Process the file with the functionToRun\n console.info('Change detected: ', relative(baseDir, filePath));\n const dictionaries = await buildDictionary(filePath);\n\n await createTypes(dictionaries);\n console.info('[intlayer] TypeScript types built');\n })\n .on('error', (error) => {\n console.error('Watcher error:', error);\n });\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SA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,eAAe,MAAM,gBAAgB,QAAQ;AAEnD,UAAM,YAAY,YAAY;AAC9B,YAAQ,KAAK,mCAAmC;AAAA,EAClD,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,YAAQ,MAAM,kBAAkB,KAAK;AAAA,EACvC,CAAC;AACL;","names":[]}
@@ -11,6 +11,10 @@ const { content } = getConfiguration();
11
11
  const { typesDir } = content;
12
12
  const isESModule = typeof import.meta.url === "string";
13
13
  const requireFunction = isESModule ? createRequire(import.meta.url) : require;
14
+ const requireUncached = (module) => {
15
+ delete requireFunction.cache[requireFunction.resolve(module)];
16
+ return requireFunction(module);
17
+ };
14
18
  const kebabCaseToCammelCase = (name) => name.split(/[\s\-_]+/).map((word, index) => {
15
19
  if (index === 0) {
16
20
  return word;
@@ -49,7 +53,7 @@ const createTypes = async (dictionariesPaths) => {
49
53
  mkdirSync(typesDir, { recursive: true });
50
54
  }
51
55
  for (const dictionaryPath of dictionariesPaths) {
52
- const dictionary = requireFunction(dictionaryPath);
56
+ const dictionary = requireUncached(dictionaryPath);
53
57
  const dictionaryName = dictionary.id;
54
58
  const dictionaryNameCamelCase = kebabCaseToCammelCase(dictionaryName) + "Content";
55
59
  const dictionaryContentString = JSON.stringify(dictionary);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n quicktype,\n InputData,\n jsonInputForTargetLanguage,\n} from 'quicktype-core';\n\nconst { content } = getConfiguration();\nconst { typesDir } = content;\n\nconst isESModule = typeof import.meta.url === 'string';\nconst requireFunction = isESModule ? createRequire(import.meta.url) : require;\n\nconst kebabCaseToCammelCase = (name: string): string =>\n name\n .split(/[\\s\\-_]+/) // Regular expression to match space, hyphen, or underscore\n .map((word, index) => {\n if (index === 0) {\n return word; // Return the first word as is\n }\n return word.charAt(0).toUpperCase() + word.slice(1); // Capitalize the first letter of subsequent words\n })\n .join(''); // Join all the segments into one string\n\nexport const generateTypeScriptType = async (\n typeName: string,\n jsonString: string\n) => {\n const { lines } = await quicktypeJSON(typeName, jsonString);\n\n const linesString: string = lines.join('\\n');\n\n return linesString;\n};\n\nconst quicktypeJSON = async (typeName: string, jsonString: string) => {\n const jsonInput = jsonInputForTargetLanguage('typescript');\n\n // We could add multiple samples for the same desired\n // type, or many sources for other types. Here we're\n // just making one type from one piece of sample JSON.\n\n await jsonInput.addSource({\n name: typeName,\n samples: [jsonString],\n });\n\n const inputData = new InputData();\n inputData.addInput(jsonInput);\n\n return await quicktype({\n inputData,\n lang: 'typescript',\n alphabetizeProperties: true,\n rendererOptions: {\n 'just-types': 'true',\n 'explicit-unions': 'true',\n 'acronym-style': 'camel',\n 'prefer-types': 'true',\n readonly: 'false',\n },\n });\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[]\n): Promise<string[]> => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireFunction(dictionaryPath);\n const dictionaryName: string = dictionary.id;\n const dictionaryNameCamelCase: string =\n kebabCaseToCammelCase(dictionaryName) + 'Content';\n\n const dictionaryContentString: string = JSON.stringify(dictionary);\n\n const typeDefinition: string = await generateTypeScriptType(\n dictionaryNameCamelCase,\n dictionaryContentString\n );\n\n const outputPath: string = resolve(typesDir, `${dictionaryName}.d.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAEjC;AAA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iBAAyB,WAAW;AAC1C,UAAM,0BACJ,sBAAsB,cAAc,IAAI;AAE1C,UAAM,0BAAkC,KAAK,UAAU,UAAU;AAEjE,UAAM,iBAAyB,MAAM;AAAA,MACnC;AAAA,MACA;AAAA,IACF;AAEA,UAAM,aAAqB,QAAQ,UAAU,GAAG,cAAc,OAAO;AAErE,kBAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { createRequire } from 'module';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport {\n quicktype,\n InputData,\n jsonInputForTargetLanguage,\n} from 'quicktype-core';\n\nconst { content } = getConfiguration();\nconst { typesDir } = content;\n\nconst isESModule = typeof import.meta.url === 'string';\nconst requireFunction = isESModule ? createRequire(import.meta.url) : require;\n\nconst requireUncached = (module: string) => {\n delete requireFunction.cache[requireFunction.resolve(module)];\n return requireFunction(module);\n};\n\nconst kebabCaseToCammelCase = (name: string): string =>\n name\n .split(/[\\s\\-_]+/) // Regular expression to match space, hyphen, or underscore\n .map((word, index) => {\n if (index === 0) {\n return word; // Return the first word as is\n }\n return word.charAt(0).toUpperCase() + word.slice(1); // Capitalize the first letter of subsequent words\n })\n .join(''); // Join all the segments into one string\n\nexport const generateTypeScriptType = async (\n typeName: string,\n jsonString: string\n) => {\n const { lines } = await quicktypeJSON(typeName, jsonString);\n\n const linesString: string = lines.join('\\n');\n\n return linesString;\n};\n\nconst quicktypeJSON = async (typeName: string, jsonString: string) => {\n const jsonInput = jsonInputForTargetLanguage('typescript');\n\n // We could add multiple samples for the same desired\n // type, or many sources for other types. Here we're\n // just making one type from one piece of sample JSON.\n\n await jsonInput.addSource({\n name: typeName,\n samples: [jsonString],\n });\n\n const inputData = new InputData();\n inputData.addInput(jsonInput);\n\n return await quicktype({\n inputData,\n lang: 'typescript',\n alphabetizeProperties: true,\n rendererOptions: {\n 'just-types': 'true',\n 'explicit-unions': 'true',\n 'acronym-style': 'camel',\n 'prefer-types': 'true',\n readonly: 'false',\n },\n });\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = async (\n dictionariesPaths: string[]\n): Promise<string[]> => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const dictionary: Dictionary = requireUncached(dictionaryPath);\n const dictionaryName: string = dictionary.id;\n const dictionaryNameCamelCase: string =\n kebabCaseToCammelCase(dictionaryName) + 'Content';\n\n const dictionaryContentString: string = JSON.stringify(dictionary);\n\n const typeDefinition: string = await generateTypeScriptType(\n dictionaryNameCamelCase,\n dictionaryContentString\n );\n\n const outputPath: string = resolve(typesDir, `${dictionaryName}.d.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAEjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,MAAM,EAAE,SAAS,IAAI;AAErB,MAAM,aAAa,OAAO,YAAY,QAAQ;AAC9C,MAAM,kBAAkB,aAAa,cAAc,YAAY,GAAG,IAAI;AAEtE,MAAM,kBAAkB,CAAC,WAAmB;AAC1C,SAAO,gBAAgB,MAAM,gBAAgB,QAAQ,MAAM,CAAC;AAC5D,SAAO,gBAAgB,MAAM;AAC/B;AAEA,MAAM,wBAAwB,CAAC,SAC7B,KACG,MAAM,UAAU,EAChB,IAAI,CAAC,MAAM,UAAU;AACpB,MAAI,U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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/chokidar",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "private": false,
5
5
  "description": "Chokidar application for IntLayer - Transpile IntLayer declaration files into dictionaries.",
6
6
  "keywords": [
@@ -52,9 +52,9 @@
52
52
  "quicktype-core": "^23.0.170",
53
53
  "react": "^18.3.1",
54
54
  "rimraf": "5.0.5",
55
- "@intlayer/config": "^2.0.10",
56
- "@intlayer/core": "^2.0.10",
57
- "intlayer": "^2.0.10"
55
+ "@intlayer/config": "^2.0.11",
56
+ "@intlayer/core": "^2.0.11",
57
+ "intlayer": "^2.0.11"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@changesets/cli": "2.27.1",