susee-utils 0.0.2

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 ADDED
@@ -0,0 +1,201 @@
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 owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ <!-- markdownlint-disable MD033 -->
2
+ <!-- markdownlint-disable MD041 -->
3
+ <div align="center">
4
+ <img src="https://susee.phothin.dev/logo/susee.webp" width="160" height="160" alt="susee" />
5
+ <h1>Susee Utilities</h1>
6
+ </div>
7
+
8
+ Utilities for suseejs
9
+
10
+ ```sh
11
+ npm i -D susee-utils
12
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ const fs = require("node:fs");
3
+ const path = require("node:path");
4
+ const tcolor = require("susee-tcolor");
5
+ const ts = require("typescript");
6
+ var utils;
7
+ (function (utils) {
8
+ /**
9
+ * Returns an object with three functions: setPrefix, getName, getPrefix.
10
+ * setPrefix sets a prefix for a given key.
11
+ * getName returns a unique name based on the given prefix and input.
12
+ * getPrefix returns the prefix for a given key.
13
+ *
14
+ */
15
+ function uniqueName() {
16
+ const storedPrefix = new Map();
17
+ const obj = {
18
+ setPrefix({ key, value }) {
19
+ if (storedPrefix.has(key)) {
20
+ console.warn(`${key} already exist`);
21
+ throw new Error();
22
+ }
23
+ storedPrefix.set(key, [value, 0]);
24
+ return obj;
25
+ },
26
+ getName(key, input) {
27
+ const [prefix, count] = storedPrefix.get(key) || [];
28
+ const _name = prefix
29
+ ? `${prefix}${input}_${(count ?? 0) + 1}`
30
+ : `$nyein${input}_${(count ?? 0) + 1}`;
31
+ storedPrefix.set(key, [prefix ?? "$nyein", (count ?? 0) + 1]);
32
+ return _name;
33
+ },
34
+ getPrefix(key) {
35
+ const [prefix] = storedPrefix.get(key) || [];
36
+ return prefix;
37
+ },
38
+ };
39
+ return obj;
40
+ }
41
+ utils.uniqueName = uniqueName;
42
+ /**
43
+ * Creates a new Error object with the given message and options.
44
+ * @param {string} [message] - The error message.
45
+ * @param {ErrorOptions} [options] - The error options.
46
+ * @returns {Error} The created Error object.
47
+ */
48
+ function emitError(message, options) {
49
+ return new Error(message, options);
50
+ } // function utils.emitError
51
+ utils.emitError = emitError;
52
+ /**
53
+ * Returns a promise that resolves after a specified amount of time.
54
+ * @param {number} time - The amount of time to wait in milliseconds.
55
+ * @returns {Promise<void>} A promise that resolves after the specified amount of time.
56
+ */
57
+ utils.wait = (time) => new Promise((resolve) => setTimeout(resolve, time)); // function utils.wait
58
+ /**
59
+ * Finds all properties in a given node.
60
+ * @param {ts.Node} node - The node to search.
61
+ * @returns {string[]} An array of property names.
62
+ */
63
+ function findProperty(node) {
64
+ const properties = [];
65
+ if (ts.isPropertyAccessExpression(node) &&
66
+ ts.isIdentifier(node.expression)) {
67
+ properties.push(node.expression.text);
68
+ }
69
+ node.forEachChild((n) => findProperty(n));
70
+ return properties;
71
+ } // function utils.findProperty
72
+ utils.findProperty = findProperty;
73
+ let str;
74
+ (function (str_1) {
75
+ /**
76
+ * Splits a camelCase string into a space-separated string.
77
+ * @param {string} str - The string to split.
78
+ * @returns {string} The split string.
79
+ */
80
+ function splitCamelCase(str) {
81
+ const splitString = str
82
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
83
+ .replace(/(_|-|\/)([a-z] || [A-Z])/g, " ")
84
+ .replace(/([A-Z])/g, (match) => match.toLowerCase())
85
+ .replace(/^([a-z])/, (match) => match.toUpperCase());
86
+ return splitString;
87
+ } // function utils.str.splitCamelCase
88
+ str_1.splitCamelCase = splitCamelCase;
89
+ })(str = utils.str || (utils.str = {})); // namespace utils.str
90
+ let file;
91
+ (function (file_1) {
92
+ file_1.resolvePath = ts.sys.resolvePath;
93
+ file_1.fileExists = ts.sys.fileExists;
94
+ file_1.directoryExists = ts.sys.directoryExists;
95
+ file_1.createDirectory = ts.sys.createDirectory;
96
+ file_1.readDirectory = ts.sys.readDirectory;
97
+ function deleteFile(filePath) {
98
+ filePath = file_1.resolvePath(filePath);
99
+ if (file_1.fileExists(filePath) && typeof ts.sys.deleteFile === "function") {
100
+ ts.sys.deleteFile(filePath);
101
+ }
102
+ } // function utils.file.deleteFile
103
+ file_1.deleteFile = deleteFile;
104
+ /**
105
+ * Clears a folder by deleting all its contents.
106
+ * @param {string} folderPath - The path to the folder to clear.
107
+ * @throws {Error} If the folder does not exist.
108
+ */
109
+ async function clearFolder(folderPath) {
110
+ folderPath = path.resolve(process.cwd(), folderPath);
111
+ try {
112
+ const entries = await fs.promises.readdir(folderPath, {
113
+ withFileTypes: true,
114
+ });
115
+ await Promise.all(entries.map((entry) => fs.promises.rm(path.join(folderPath, entry.name), {
116
+ recursive: true,
117
+ })));
118
+ }
119
+ catch (error) {
120
+ // biome-ignore lint/suspicious/noExplicitAny: error code
121
+ if (error.code !== "ENOENT") {
122
+ throw error;
123
+ }
124
+ }
125
+ } // function utils.file.clearFolder
126
+ file_1.clearFolder = clearFolder;
127
+ /**
128
+ * Writes a file to disk.
129
+ * @param {string} file - The file path to write to.
130
+ * @param {string} content - The content to write to the file.
131
+ * @returns {Promise<void>} A promise that resolves when the file has been written.
132
+ */
133
+ async function writeFile(file, content) {
134
+ const filePath = ts.sys.resolvePath(file);
135
+ const dir = path.dirname(filePath);
136
+ if (!ts.sys.directoryExists(dir)) {
137
+ await fs.promises.mkdir(dir, { recursive: true });
138
+ }
139
+ await utils.wait(500);
140
+ await fs.promises.writeFile(filePath, content);
141
+ } // function utils.file.writeFile
142
+ file_1.writeFile = writeFile;
143
+ /**
144
+ * Reads a file from disk.
145
+ * @param {string} filePath - The file path to read from.
146
+ * @returns {string} The content of the file.
147
+ * @throws {Error} If the file does not exist.
148
+ */
149
+ function readFile(filePath) {
150
+ const resolvedFilePath = file_1.resolvePath(filePath);
151
+ if (!file_1.fileExists(resolvedFilePath))
152
+ throw emitError(`${filePath} does not exist.`);
153
+ const content = ts.sys.readFile(resolvedFilePath, "utf8");
154
+ if (content) {
155
+ return content;
156
+ }
157
+ else {
158
+ console.warn(`When reading ${filePath} received content is blank.`);
159
+ return "";
160
+ }
161
+ } // function utils.file.readFile
162
+ file_1.readFile = readFile;
163
+ })(file = utils.file || (utils.file = {})); // namespace utils.file
164
+ let check;
165
+ (function (check) {
166
+ /**
167
+ * Checks the given source file for module type (CommonJS or ESM).
168
+ * @param sourceFile - The source file to check.
169
+ * @param file - The file path of the source file.
170
+ * @returns An object containing the results of the check.
171
+ * @returns {isCommonJs: boolean, isEsm: boolean}
172
+ */
173
+ check.moduleType = (sourceFile, file) => {
174
+ let _esmCount = 0;
175
+ let cjsCount = 0;
176
+ let unknownCount = 0;
177
+ try {
178
+ let hasESMImports = false;
179
+ let hasCommonJS = false;
180
+ // Walk through the AST to detect module syntax
181
+ function walk(node) {
182
+ // Check for ESM import/export syntax
183
+ if (ts.isImportDeclaration(node) ||
184
+ ts.isImportEqualsDeclaration(node) ||
185
+ ts.isExportDeclaration(node) ||
186
+ ts.isExportSpecifier(node) ||
187
+ ts.isExportAssignment(node)) {
188
+ hasESMImports = true;
189
+ }
190
+ // Check for export modifier on declarations
191
+ if ((ts.isVariableStatement(node) ||
192
+ ts.isFunctionDeclaration(node) ||
193
+ ts.isInterfaceDeclaration(node) ||
194
+ ts.isTypeAliasDeclaration(node) ||
195
+ ts.isEnumDeclaration(node) ||
196
+ ts.isClassDeclaration(node)) &&
197
+ node.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword)) {
198
+ hasESMImports = true;
199
+ }
200
+ // Check for CommonJS require/exports
201
+ if (ts.isCallExpression(node)) {
202
+ if (ts.isIdentifier(node.expression) &&
203
+ node.expression.text === "require" &&
204
+ node.arguments.length > 0) {
205
+ hasCommonJS = true;
206
+ }
207
+ }
208
+ // Check for module.exports or exports.xxx
209
+ if (ts.isPropertyAccessExpression(node)) {
210
+ const text = node.getText(sourceFile);
211
+ if (text.startsWith("module.exports") ||
212
+ text.startsWith("exports.")) {
213
+ hasCommonJS = true;
214
+ }
215
+ }
216
+ // Continue walking the AST
217
+ ts.forEachChild(node, walk);
218
+ } //---
219
+ walk(sourceFile);
220
+ // Determine the module format based on what we found
221
+ if (hasESMImports && !hasCommonJS) {
222
+ _esmCount++;
223
+ }
224
+ else if (hasCommonJS && !hasESMImports) {
225
+ cjsCount++;
226
+ }
227
+ else if (hasESMImports && hasCommonJS) {
228
+ // Mixed - probably ESM with dynamic imports or similar
229
+ _esmCount++;
230
+ }
231
+ }
232
+ catch (error) {
233
+ console.error(tcolor.magenta(`Error checking module format for ${file} : \n ${error}`));
234
+ unknownCount++;
235
+ }
236
+ if (unknownCount > 0) {
237
+ console.error(tcolor.magenta(`Error checking module format.`));
238
+ ts.sys.exit(1);
239
+ }
240
+ return {
241
+ isCommonJs: cjsCount > 0,
242
+ isEsm: _esmCount > 0,
243
+ };
244
+ }; // function utils.check.moduleType
245
+ /**
246
+ * Checks if the given code string contains JSX syntax.
247
+ * @param code The content of the file as a string.
248
+ * @returns true if the file contains JSX, false otherwise.
249
+ */
250
+ function isJsxContent(code) {
251
+ const sourceFile = ts.createSourceFile("file.tsx", code, ts.ScriptTarget.Latest,
252
+ /*setParentNodes*/ true, ts.ScriptKind.TSX);
253
+ let containsJsx = false;
254
+ function visitor(node) {
255
+ // Check for JSX Elements, Self Closing Elements, or JSX Fragments
256
+ if (ts.isJsxElement(node) ||
257
+ ts.isJsxSelfClosingElement(node) ||
258
+ ts.isJsxFragment(node)) {
259
+ containsJsx = true;
260
+ return;
261
+ }
262
+ ts.forEachChild(node, visitor);
263
+ }
264
+ visitor(sourceFile);
265
+ return containsJsx;
266
+ } //function utils.check.isJsxContent
267
+ check.isJsxContent = isJsxContent;
268
+ /**
269
+ * Checks if a given node is inside a namespace declaration.
270
+ * It does this by traversing up the parent nodes until it finds a module declaration with the namespace flag set.
271
+ * @param n The node to check.
272
+ * @returns true if the node is inside a namespace declaration, false otherwise.
273
+ */
274
+ check.isInsideNamespace = (n) => {
275
+ let current = n.parent;
276
+ while (current) {
277
+ if (ts.isModuleDeclaration(current) &&
278
+ current.flags === ts.NodeFlags.Namespace) {
279
+ return true;
280
+ }
281
+ current = current.parent;
282
+ }
283
+ return false;
284
+ }; //function utils.check.isInsideNamespace
285
+ })(check = utils.check || (utils.check = {})); // namespace utils.check
286
+ let plugins;
287
+ (function (plugins_1) {
288
+ /**
289
+ * Applies plugins that modify dependencies files.
290
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
291
+ * @param depFiles The dependencies files object to modify.
292
+ * @param compilerOptions The TypeScript compiler options.
293
+ * @returns The modified dependencies files object.
294
+ */
295
+ async function depPluginParser(plugins, depFiles, compilerOptions) {
296
+ if (plugins.length) {
297
+ for (const plugin of plugins) {
298
+ const _plugin = typeof plugin === "function" ? plugin() : plugin;
299
+ if (_plugin.type === "dependency") {
300
+ if (_plugin.async) {
301
+ depFiles = await _plugin.func(depFiles, compilerOptions);
302
+ }
303
+ else {
304
+ depFiles = _plugin.func(depFiles, compilerOptions);
305
+ }
306
+ }
307
+ }
308
+ }
309
+ return depFiles;
310
+ } //function utils.plugins.depPluginParser
311
+ plugins_1.depPluginParser = depPluginParser;
312
+ /**
313
+ * Applies pre-process or post-process plugins that modify code.
314
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
315
+ * @param code The code string to modify.
316
+ * @param file The file name of the code string.
317
+ * @returns The modified code string.
318
+ */
319
+ async function processPluginParser(plugins, code, file) {
320
+ if (plugins.length) {
321
+ for (const plugin of plugins) {
322
+ const _plugin = typeof plugin === "function" ? plugin() : plugin;
323
+ if (_plugin.type === "pre-process" ||
324
+ _plugin.type === "post-process") {
325
+ if (_plugin.async) {
326
+ code = await _plugin.func(code, file);
327
+ }
328
+ else {
329
+ code = _plugin.func(code, file);
330
+ }
331
+ }
332
+ }
333
+ }
334
+ return code;
335
+ } //function utils.plugins.processPluginParser
336
+ plugins_1.processPluginParser = processPluginParser;
337
+ })(plugins = utils.plugins || (utils.plugins = {})); // namespace utils.plugins
338
+ })(utils || (utils = {})); // namespace utils
339
+ module.exports = utils;
340
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":";AAAA,8BAA+B;AAC/B,kCAAmC;AACnC,uCAAwC;AACxC,iCAAkC;AAGlC,IAAU,KAAK,CAgXd;AAhXD,WAAU,KAAK;IACb;;;;;;OAMG;IACH,SAAgB,UAAU;QACxB,MAAM,YAAY,GAAkC,IAAI,GAAG,EAAE,CAAC;QAE9D,MAAM,GAAG,GAAG;YACV,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAkC;gBACtD,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,gBAAgB,CAAC,CAAC;oBACrC,MAAM,IAAI,KAAK,EAAE,CAAC;gBACpB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;gBAClC,OAAO,GAAG,CAAC;YACb,CAAC;YACD,OAAO,CAAC,GAAW,EAAE,KAAa;gBAChC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;gBAEpD,MAAM,KAAK,GAAG,MAAM;oBAClB,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE;oBACzC,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,IAAI,QAAQ,EAAE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
+ import ts = require("typescript");
2
+ import SuseeTypes = require("susee-types");
3
+ declare namespace utils {
4
+ /**
5
+ * Returns an object with three functions: setPrefix, getName, getPrefix.
6
+ * setPrefix sets a prefix for a given key.
7
+ * getName returns a unique name based on the given prefix and input.
8
+ * getPrefix returns the prefix for a given key.
9
+ *
10
+ */
11
+ function uniqueName(): {
12
+ setPrefix({ key, value }: {
13
+ key: string;
14
+ value: string;
15
+ }): /*elided*/ any;
16
+ getName(key: string, input: string): string;
17
+ getPrefix(key: string): string | undefined;
18
+ };
19
+ /**
20
+ * Creates a new Error object with the given message and options.
21
+ * @param {string} [message] - The error message.
22
+ * @param {ErrorOptions} [options] - The error options.
23
+ * @returns {Error} The created Error object.
24
+ */
25
+ function emitError(message?: string, options?: ErrorOptions): Error;
26
+ /**
27
+ * Returns a promise that resolves after a specified amount of time.
28
+ * @param {number} time - The amount of time to wait in milliseconds.
29
+ * @returns {Promise<void>} A promise that resolves after the specified amount of time.
30
+ */
31
+ const wait: (time: number) => Promise<void>;
32
+ /**
33
+ * Finds all properties in a given node.
34
+ * @param {ts.Node} node - The node to search.
35
+ * @returns {string[]} An array of property names.
36
+ */
37
+ function findProperty(node: ts.Node): string[];
38
+ namespace str {
39
+ /**
40
+ * Splits a camelCase string into a space-separated string.
41
+ * @param {string} str - The string to split.
42
+ * @returns {string} The split string.
43
+ */
44
+ function splitCamelCase(str: string): string;
45
+ }
46
+ namespace file {
47
+ const resolvePath: (path: string) => string;
48
+ const fileExists: (path: string) => boolean;
49
+ const directoryExists: (path: string) => boolean;
50
+ const createDirectory: (path: string) => void;
51
+ const readDirectory: (path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number) => string[];
52
+ function deleteFile(filePath: string): void;
53
+ /**
54
+ * Clears a folder by deleting all its contents.
55
+ * @param {string} folderPath - The path to the folder to clear.
56
+ * @throws {Error} If the folder does not exist.
57
+ */
58
+ function clearFolder(folderPath: string): Promise<void>;
59
+ /**
60
+ * Writes a file to disk.
61
+ * @param {string} file - The file path to write to.
62
+ * @param {string} content - The content to write to the file.
63
+ * @returns {Promise<void>} A promise that resolves when the file has been written.
64
+ */
65
+ function writeFile(file: string, content: string): Promise<void>;
66
+ /**
67
+ * Reads a file from disk.
68
+ * @param {string} filePath - The file path to read from.
69
+ * @returns {string} The content of the file.
70
+ * @throws {Error} If the file does not exist.
71
+ */
72
+ function readFile(filePath: string): string;
73
+ }
74
+ namespace check {
75
+ /**
76
+ * Checks the given source file for module type (CommonJS or ESM).
77
+ * @param sourceFile - The source file to check.
78
+ * @param file - The file path of the source file.
79
+ * @returns An object containing the results of the check.
80
+ * @returns {isCommonJs: boolean, isEsm: boolean}
81
+ */
82
+ const moduleType: (sourceFile: ts.SourceFile, file: string) => {
83
+ isCommonJs: boolean;
84
+ isEsm: boolean;
85
+ };
86
+ /**
87
+ * Checks if the given code string contains JSX syntax.
88
+ * @param code The content of the file as a string.
89
+ * @returns true if the file contains JSX, false otherwise.
90
+ */
91
+ function isJsxContent(code: string): boolean;
92
+ /**
93
+ * Checks if a given node is inside a namespace declaration.
94
+ * It does this by traversing up the parent nodes until it finds a module declaration with the namespace flag set.
95
+ * @param n The node to check.
96
+ * @returns true if the node is inside a namespace declaration, false otherwise.
97
+ */
98
+ const isInsideNamespace: (n: ts.Node) => boolean;
99
+ }
100
+ namespace plugins {
101
+ /**
102
+ * Applies plugins that modify dependencies files.
103
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
104
+ * @param depFiles The dependencies files object to modify.
105
+ * @param compilerOptions The TypeScript compiler options.
106
+ * @returns The modified dependencies files object.
107
+ */
108
+ function depPluginParser(plugins: (SuseeTypes.SuseePlugin | SuseeTypes.SuseePluginFunction)[], depFiles: SuseeTypes.DependenciesFiles, compilerOptions: ts.CompilerOptions): Promise<SuseeTypes.DependenciesFiles>;
109
+ /**
110
+ * Applies pre-process or post-process plugins that modify code.
111
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
112
+ * @param code The code string to modify.
113
+ * @param file The file name of the code string.
114
+ * @returns The modified code string.
115
+ */
116
+ function processPluginParser(plugins: (SuseeTypes.SuseePlugin | SuseeTypes.SuseePluginFunction)[], code: string, file?: string | undefined): Promise<string>;
117
+ }
118
+ }
119
+ export = utils;
120
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AAClC,OAAO,UAAU,GAAG,QAAQ,aAAa,CAAC,CAAC;AAE3C,kBAAU,KAAK,CAAC;IACd;;;;;;OAMG;IACH,SAAgB,UAAU;kCAII;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE;qBAQ3C,MAAM,SAAS,MAAM;uBASnB,MAAM;MAMxB;IACD;;;;;OAKG;IACH,SAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAEzE;IACD;;;;OAIG;IACI,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CACK,CAAC;IACtD;;;;OAIG;IACH,SAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,EAAE,CAWpD;IACD,UAAiB,GAAG,CAAC;QACnB;;;;WAIG;QACH,SAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOlD;KACF;IACD,UAAiB,IAAI,CAAC;QACb,MAAM,WAAW,0BAAqB,CAAC;QACvC,MAAM,UAAU,2BAAoB,CAAC;QACrC,MAAM,eAAe,2BAAyB,CAAC;QAC/C,MAAM,eAAe,wBAAyB,CAAC;QAC/C,MAAM,aAAa,sIAAuB,CAAC;QAClD,SAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,QAK1C;QACD;;;;WAIG;QACH,SAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,iBAmBnD;QACD;;;;;WAKG;QACH,SAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAQf;QACD;;;;;WAKG;QACH,SAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWjD;KACF;IACD,UAAiB,KAAK,CAAC;QACrB;;;;;;WAMG;QACI,MAAM,UAAU,GAAI,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,MAAM;;;SA0FjE,CAAC;QACF;;;;WAIG;QACH,SAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA2BlD;QACD;;;;;WAKG;QACI,MAAM,iBAAiB,GAAI,GAAG,EAAE,CAAC,IAAI,KAAG,OAY9C,CAAC;KACH;IACD,UAAiB,OAAO,CAAC;QACvB;;;;;;WAMG;QACH,SAAsB,eAAe,CACnC,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,mBAAmB,CAAC,EAAE,EACpE,QAAQ,EAAE,UAAU,CAAC,iBAAiB,EACtC,eAAe,EAAE,EAAE,CAAC,eAAe,yCAepC;QAED;;;;;;WAMG;QACH,SAAsB,mBAAmB,CACvC,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,mBAAmB,CAAC,EAAE,EACpE,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,mBAkB1B;KACF;CACF;AAED,SAAS,KAAK,CAAC"}
@@ -0,0 +1,120 @@
1
+ import type * as SuseeTypes from "susee-types";
2
+ import ts from "typescript";
3
+ declare namespace utils {
4
+ /**
5
+ * Returns an object with three functions: setPrefix, getName, getPrefix.
6
+ * setPrefix sets a prefix for a given key.
7
+ * getName returns a unique name based on the given prefix and input.
8
+ * getPrefix returns the prefix for a given key.
9
+ *
10
+ */
11
+ function uniqueName(): {
12
+ setPrefix({ key, value }: {
13
+ key: string;
14
+ value: string;
15
+ }): /*elided*/ any;
16
+ getName(key: string, input: string): string;
17
+ getPrefix(key: string): string | undefined;
18
+ };
19
+ /**
20
+ * Creates a new Error object with the given message and options.
21
+ * @param {string} [message] - The error message.
22
+ * @param {ErrorOptions} [options] - The error options.
23
+ * @returns {Error} The created Error object.
24
+ */
25
+ function emitError(message?: string, options?: ErrorOptions): Error;
26
+ /**
27
+ * Returns a promise that resolves after a specified amount of time.
28
+ * @param {number} time - The amount of time to wait in milliseconds.
29
+ * @returns {Promise<void>} A promise that resolves after the specified amount of time.
30
+ */
31
+ const wait: (time: number) => Promise<void>;
32
+ /**
33
+ * Finds all properties in a given node.
34
+ * @param {ts.Node} node - The node to search.
35
+ * @returns {string[]} An array of property names.
36
+ */
37
+ function findProperty(node: ts.Node): string[];
38
+ namespace str {
39
+ /**
40
+ * Splits a camelCase string into a space-separated string.
41
+ * @param {string} str - The string to split.
42
+ * @returns {string} The split string.
43
+ */
44
+ function splitCamelCase(str: string): string;
45
+ }
46
+ namespace file {
47
+ const resolvePath: (path: string) => string;
48
+ const fileExists: (path: string) => boolean;
49
+ const directoryExists: (path: string) => boolean;
50
+ const createDirectory: (path: string) => void;
51
+ const readDirectory: (path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number) => string[];
52
+ function deleteFile(filePath: string): void;
53
+ /**
54
+ * Clears a folder by deleting all its contents.
55
+ * @param {string} folderPath - The path to the folder to clear.
56
+ * @throws {Error} If the folder does not exist.
57
+ */
58
+ function clearFolder(folderPath: string): Promise<void>;
59
+ /**
60
+ * Writes a file to disk.
61
+ * @param {string} file - The file path to write to.
62
+ * @param {string} content - The content to write to the file.
63
+ * @returns {Promise<void>} A promise that resolves when the file has been written.
64
+ */
65
+ function writeFile(file: string, content: string): Promise<void>;
66
+ /**
67
+ * Reads a file from disk.
68
+ * @param {string} filePath - The file path to read from.
69
+ * @returns {string} The content of the file.
70
+ * @throws {Error} If the file does not exist.
71
+ */
72
+ function readFile(filePath: string): string;
73
+ }
74
+ namespace check {
75
+ /**
76
+ * Checks the given source file for module type (CommonJS or ESM).
77
+ * @param sourceFile - The source file to check.
78
+ * @param file - The file path of the source file.
79
+ * @returns An object containing the results of the check.
80
+ * @returns {isCommonJs: boolean, isEsm: boolean}
81
+ */
82
+ const moduleType: (sourceFile: ts.SourceFile, file: string) => {
83
+ isCommonJs: boolean;
84
+ isEsm: boolean;
85
+ };
86
+ /**
87
+ * Checks if the given code string contains JSX syntax.
88
+ * @param code The content of the file as a string.
89
+ * @returns true if the file contains JSX, false otherwise.
90
+ */
91
+ function isJsxContent(code: string): boolean;
92
+ /**
93
+ * Checks if a given node is inside a namespace declaration.
94
+ * It does this by traversing up the parent nodes until it finds a module declaration with the namespace flag set.
95
+ * @param n The node to check.
96
+ * @returns true if the node is inside a namespace declaration, false otherwise.
97
+ */
98
+ const isInsideNamespace: (n: ts.Node) => boolean;
99
+ }
100
+ namespace plugins {
101
+ /**
102
+ * Applies plugins that modify dependencies files.
103
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
104
+ * @param depFiles The dependencies files object to modify.
105
+ * @param compilerOptions The TypeScript compiler options.
106
+ * @returns The modified dependencies files object.
107
+ */
108
+ function depPluginParser(plugins: (SuseeTypes.SuseePlugin | SuseeTypes.SuseePluginFunction)[], depFiles: SuseeTypes.DependenciesFiles, compilerOptions: ts.CompilerOptions): Promise<SuseeTypes.DependenciesFiles>;
109
+ /**
110
+ * Applies pre-process or post-process plugins that modify code.
111
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
112
+ * @param code The code string to modify.
113
+ * @param file The file name of the code string.
114
+ * @returns The modified code string.
115
+ */
116
+ function processPluginParser(plugins: (SuseeTypes.SuseePlugin | SuseeTypes.SuseePluginFunction)[], code: string, file?: string | undefined): Promise<string>;
117
+ }
118
+ }
119
+ export default utils;
120
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,UAAU,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,kBAAU,KAAK,CAAC;IACd;;;;;;OAMG;IACH,SAAgB,UAAU;kCAII;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE;qBAQ3C,MAAM,SAAS,MAAM;uBASnB,MAAM;MAMxB;IACD;;;;;OAKG;IACH,SAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAEzE;IACD;;;;OAIG;IACI,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,IAAI,CACK,CAAC;IACtD;;;;OAIG;IACH,SAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,EAAE,CAWpD;IACD,UAAiB,GAAG,CAAC;QACnB;;;;WAIG;QACH,SAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOlD;KACF;IACD,UAAiB,IAAI,CAAC;QACb,MAAM,WAAW,0BAAqB,CAAC;QACvC,MAAM,UAAU,2BAAoB,CAAC;QACrC,MAAM,eAAe,2BAAyB,CAAC;QAC/C,MAAM,eAAe,wBAAyB,CAAC;QAC/C,MAAM,aAAa,sIAAuB,CAAC;QAClD,SAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,QAK1C;QACD;;;;WAIG;QACH,SAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,iBAmBnD;QACD;;;;;WAKG;QACH,SAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAQf;QACD;;;;;WAKG;QACH,SAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWjD;KACF;IACD,UAAiB,KAAK,CAAC;QACrB;;;;;;WAMG;QACI,MAAM,UAAU,GAAI,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,MAAM;;;SA0FjE,CAAC;QACF;;;;WAIG;QACH,SAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA2BlD;QACD;;;;;WAKG;QACI,MAAM,iBAAiB,GAAI,GAAG,EAAE,CAAC,IAAI,KAAG,OAY9C,CAAC;KACH;IACD,UAAiB,OAAO,CAAC;QACvB;;;;;;WAMG;QACH,SAAsB,eAAe,CACnC,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,mBAAmB,CAAC,EAAE,EACpE,QAAQ,EAAE,UAAU,CAAC,iBAAiB,EACtC,eAAe,EAAE,EAAE,CAAC,eAAe,yCAepC;QAED;;;;;;WAMG;QACH,SAAsB,mBAAmB,CACvC,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,mBAAmB,CAAC,EAAE,EACpE,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,mBAkB1B;KACF;CACF;AAED,eAAe,KAAK,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,339 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import tcolor from "susee-tcolor";
4
+ import ts from "typescript";
5
+ var utils;
6
+ (function (utils) {
7
+ /**
8
+ * Returns an object with three functions: setPrefix, getName, getPrefix.
9
+ * setPrefix sets a prefix for a given key.
10
+ * getName returns a unique name based on the given prefix and input.
11
+ * getPrefix returns the prefix for a given key.
12
+ *
13
+ */
14
+ function uniqueName() {
15
+ const storedPrefix = new Map();
16
+ const obj = {
17
+ setPrefix({ key, value }) {
18
+ if (storedPrefix.has(key)) {
19
+ console.warn(`${key} already exist`);
20
+ throw new Error();
21
+ }
22
+ storedPrefix.set(key, [value, 0]);
23
+ return obj;
24
+ },
25
+ getName(key, input) {
26
+ const [prefix, count] = storedPrefix.get(key) || [];
27
+ const _name = prefix
28
+ ? `${prefix}${input}_${(count ?? 0) + 1}`
29
+ : `$nyein${input}_${(count ?? 0) + 1}`;
30
+ storedPrefix.set(key, [prefix ?? "$nyein", (count ?? 0) + 1]);
31
+ return _name;
32
+ },
33
+ getPrefix(key) {
34
+ const [prefix] = storedPrefix.get(key) || [];
35
+ return prefix;
36
+ },
37
+ };
38
+ return obj;
39
+ }
40
+ utils.uniqueName = uniqueName;
41
+ /**
42
+ * Creates a new Error object with the given message and options.
43
+ * @param {string} [message] - The error message.
44
+ * @param {ErrorOptions} [options] - The error options.
45
+ * @returns {Error} The created Error object.
46
+ */
47
+ function emitError(message, options) {
48
+ return new Error(message, options);
49
+ } // function utils.emitError
50
+ utils.emitError = emitError;
51
+ /**
52
+ * Returns a promise that resolves after a specified amount of time.
53
+ * @param {number} time - The amount of time to wait in milliseconds.
54
+ * @returns {Promise<void>} A promise that resolves after the specified amount of time.
55
+ */
56
+ utils.wait = (time) => new Promise((resolve) => setTimeout(resolve, time)); // function utils.wait
57
+ /**
58
+ * Finds all properties in a given node.
59
+ * @param {ts.Node} node - The node to search.
60
+ * @returns {string[]} An array of property names.
61
+ */
62
+ function findProperty(node) {
63
+ const properties = [];
64
+ if (ts.isPropertyAccessExpression(node) &&
65
+ ts.isIdentifier(node.expression)) {
66
+ properties.push(node.expression.text);
67
+ }
68
+ node.forEachChild((n) => findProperty(n));
69
+ return properties;
70
+ } // function utils.findProperty
71
+ utils.findProperty = findProperty;
72
+ let str;
73
+ (function (str_1) {
74
+ /**
75
+ * Splits a camelCase string into a space-separated string.
76
+ * @param {string} str - The string to split.
77
+ * @returns {string} The split string.
78
+ */
79
+ function splitCamelCase(str) {
80
+ const splitString = str
81
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
82
+ .replace(/(_|-|\/)([a-z] || [A-Z])/g, " ")
83
+ .replace(/([A-Z])/g, (match) => match.toLowerCase())
84
+ .replace(/^([a-z])/, (match) => match.toUpperCase());
85
+ return splitString;
86
+ } // function utils.str.splitCamelCase
87
+ str_1.splitCamelCase = splitCamelCase;
88
+ })(str = utils.str || (utils.str = {})); // namespace utils.str
89
+ let file;
90
+ (function (file_1) {
91
+ file_1.resolvePath = ts.sys.resolvePath;
92
+ file_1.fileExists = ts.sys.fileExists;
93
+ file_1.directoryExists = ts.sys.directoryExists;
94
+ file_1.createDirectory = ts.sys.createDirectory;
95
+ file_1.readDirectory = ts.sys.readDirectory;
96
+ function deleteFile(filePath) {
97
+ filePath = file_1.resolvePath(filePath);
98
+ if (file_1.fileExists(filePath) && typeof ts.sys.deleteFile === "function") {
99
+ ts.sys.deleteFile(filePath);
100
+ }
101
+ } // function utils.file.deleteFile
102
+ file_1.deleteFile = deleteFile;
103
+ /**
104
+ * Clears a folder by deleting all its contents.
105
+ * @param {string} folderPath - The path to the folder to clear.
106
+ * @throws {Error} If the folder does not exist.
107
+ */
108
+ async function clearFolder(folderPath) {
109
+ folderPath = path.resolve(process.cwd(), folderPath);
110
+ try {
111
+ const entries = await fs.promises.readdir(folderPath, {
112
+ withFileTypes: true,
113
+ });
114
+ await Promise.all(entries.map((entry) => fs.promises.rm(path.join(folderPath, entry.name), {
115
+ recursive: true,
116
+ })));
117
+ }
118
+ catch (error) {
119
+ // biome-ignore lint/suspicious/noExplicitAny: error code
120
+ if (error.code !== "ENOENT") {
121
+ throw error;
122
+ }
123
+ }
124
+ } // function utils.file.clearFolder
125
+ file_1.clearFolder = clearFolder;
126
+ /**
127
+ * Writes a file to disk.
128
+ * @param {string} file - The file path to write to.
129
+ * @param {string} content - The content to write to the file.
130
+ * @returns {Promise<void>} A promise that resolves when the file has been written.
131
+ */
132
+ async function writeFile(file, content) {
133
+ const filePath = ts.sys.resolvePath(file);
134
+ const dir = path.dirname(filePath);
135
+ if (!ts.sys.directoryExists(dir)) {
136
+ await fs.promises.mkdir(dir, { recursive: true });
137
+ }
138
+ await utils.wait(500);
139
+ await fs.promises.writeFile(filePath, content);
140
+ } // function utils.file.writeFile
141
+ file_1.writeFile = writeFile;
142
+ /**
143
+ * Reads a file from disk.
144
+ * @param {string} filePath - The file path to read from.
145
+ * @returns {string} The content of the file.
146
+ * @throws {Error} If the file does not exist.
147
+ */
148
+ function readFile(filePath) {
149
+ const resolvedFilePath = file_1.resolvePath(filePath);
150
+ if (!file_1.fileExists(resolvedFilePath))
151
+ throw emitError(`${filePath} does not exist.`);
152
+ const content = ts.sys.readFile(resolvedFilePath, "utf8");
153
+ if (content) {
154
+ return content;
155
+ }
156
+ else {
157
+ console.warn(`When reading ${filePath} received content is blank.`);
158
+ return "";
159
+ }
160
+ } // function utils.file.readFile
161
+ file_1.readFile = readFile;
162
+ })(file = utils.file || (utils.file = {})); // namespace utils.file
163
+ let check;
164
+ (function (check) {
165
+ /**
166
+ * Checks the given source file for module type (CommonJS or ESM).
167
+ * @param sourceFile - The source file to check.
168
+ * @param file - The file path of the source file.
169
+ * @returns An object containing the results of the check.
170
+ * @returns {isCommonJs: boolean, isEsm: boolean}
171
+ */
172
+ check.moduleType = (sourceFile, file) => {
173
+ let _esmCount = 0;
174
+ let cjsCount = 0;
175
+ let unknownCount = 0;
176
+ try {
177
+ let hasESMImports = false;
178
+ let hasCommonJS = false;
179
+ // Walk through the AST to detect module syntax
180
+ function walk(node) {
181
+ // Check for ESM import/export syntax
182
+ if (ts.isImportDeclaration(node) ||
183
+ ts.isImportEqualsDeclaration(node) ||
184
+ ts.isExportDeclaration(node) ||
185
+ ts.isExportSpecifier(node) ||
186
+ ts.isExportAssignment(node)) {
187
+ hasESMImports = true;
188
+ }
189
+ // Check for export modifier on declarations
190
+ if ((ts.isVariableStatement(node) ||
191
+ ts.isFunctionDeclaration(node) ||
192
+ ts.isInterfaceDeclaration(node) ||
193
+ ts.isTypeAliasDeclaration(node) ||
194
+ ts.isEnumDeclaration(node) ||
195
+ ts.isClassDeclaration(node)) &&
196
+ node.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword)) {
197
+ hasESMImports = true;
198
+ }
199
+ // Check for CommonJS require/exports
200
+ if (ts.isCallExpression(node)) {
201
+ if (ts.isIdentifier(node.expression) &&
202
+ node.expression.text === "require" &&
203
+ node.arguments.length > 0) {
204
+ hasCommonJS = true;
205
+ }
206
+ }
207
+ // Check for module.exports or exports.xxx
208
+ if (ts.isPropertyAccessExpression(node)) {
209
+ const text = node.getText(sourceFile);
210
+ if (text.startsWith("module.exports") ||
211
+ text.startsWith("exports.")) {
212
+ hasCommonJS = true;
213
+ }
214
+ }
215
+ // Continue walking the AST
216
+ ts.forEachChild(node, walk);
217
+ } //---
218
+ walk(sourceFile);
219
+ // Determine the module format based on what we found
220
+ if (hasESMImports && !hasCommonJS) {
221
+ _esmCount++;
222
+ }
223
+ else if (hasCommonJS && !hasESMImports) {
224
+ cjsCount++;
225
+ }
226
+ else if (hasESMImports && hasCommonJS) {
227
+ // Mixed - probably ESM with dynamic imports or similar
228
+ _esmCount++;
229
+ }
230
+ }
231
+ catch (error) {
232
+ console.error(tcolor.magenta(`Error checking module format for ${file} : \n ${error}`));
233
+ unknownCount++;
234
+ }
235
+ if (unknownCount > 0) {
236
+ console.error(tcolor.magenta(`Error checking module format.`));
237
+ ts.sys.exit(1);
238
+ }
239
+ return {
240
+ isCommonJs: cjsCount > 0,
241
+ isEsm: _esmCount > 0,
242
+ };
243
+ }; // function utils.check.moduleType
244
+ /**
245
+ * Checks if the given code string contains JSX syntax.
246
+ * @param code The content of the file as a string.
247
+ * @returns true if the file contains JSX, false otherwise.
248
+ */
249
+ function isJsxContent(code) {
250
+ const sourceFile = ts.createSourceFile("file.tsx", code, ts.ScriptTarget.Latest,
251
+ /*setParentNodes*/ true, ts.ScriptKind.TSX);
252
+ let containsJsx = false;
253
+ function visitor(node) {
254
+ // Check for JSX Elements, Self Closing Elements, or JSX Fragments
255
+ if (ts.isJsxElement(node) ||
256
+ ts.isJsxSelfClosingElement(node) ||
257
+ ts.isJsxFragment(node)) {
258
+ containsJsx = true;
259
+ return;
260
+ }
261
+ ts.forEachChild(node, visitor);
262
+ }
263
+ visitor(sourceFile);
264
+ return containsJsx;
265
+ } //function utils.check.isJsxContent
266
+ check.isJsxContent = isJsxContent;
267
+ /**
268
+ * Checks if a given node is inside a namespace declaration.
269
+ * It does this by traversing up the parent nodes until it finds a module declaration with the namespace flag set.
270
+ * @param n The node to check.
271
+ * @returns true if the node is inside a namespace declaration, false otherwise.
272
+ */
273
+ check.isInsideNamespace = (n) => {
274
+ let current = n.parent;
275
+ while (current) {
276
+ if (ts.isModuleDeclaration(current) &&
277
+ current.flags === ts.NodeFlags.Namespace) {
278
+ return true;
279
+ }
280
+ current = current.parent;
281
+ }
282
+ return false;
283
+ }; //function utils.check.isInsideNamespace
284
+ })(check = utils.check || (utils.check = {})); // namespace utils.check
285
+ let plugins;
286
+ (function (plugins_1) {
287
+ /**
288
+ * Applies plugins that modify dependencies files.
289
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
290
+ * @param depFiles The dependencies files object to modify.
291
+ * @param compilerOptions The TypeScript compiler options.
292
+ * @returns The modified dependencies files object.
293
+ */
294
+ async function depPluginParser(plugins, depFiles, compilerOptions) {
295
+ if (plugins.length) {
296
+ for (const plugin of plugins) {
297
+ const _plugin = typeof plugin === "function" ? plugin() : plugin;
298
+ if (_plugin.type === "dependency") {
299
+ if (_plugin.async) {
300
+ depFiles = await _plugin.func(depFiles, compilerOptions);
301
+ }
302
+ else {
303
+ depFiles = _plugin.func(depFiles, compilerOptions);
304
+ }
305
+ }
306
+ }
307
+ }
308
+ return depFiles;
309
+ } //function utils.plugins.depPluginParser
310
+ plugins_1.depPluginParser = depPluginParser;
311
+ /**
312
+ * Applies pre-process or post-process plugins that modify code.
313
+ * @param plugins An array of plugins to apply. Each plugin can be a SuseeTypes.SuseePlugin or a SuseeTypes.SuseePluginFunction.
314
+ * @param code The code string to modify.
315
+ * @param file The file name of the code string.
316
+ * @returns The modified code string.
317
+ */
318
+ async function processPluginParser(plugins, code, file) {
319
+ if (plugins.length) {
320
+ for (const plugin of plugins) {
321
+ const _plugin = typeof plugin === "function" ? plugin() : plugin;
322
+ if (_plugin.type === "pre-process" ||
323
+ _plugin.type === "post-process") {
324
+ if (_plugin.async) {
325
+ code = await _plugin.func(code, file);
326
+ }
327
+ else {
328
+ code = _plugin.func(code, file);
329
+ }
330
+ }
331
+ }
332
+ }
333
+ return code;
334
+ } //function utils.plugins.processPluginParser
335
+ plugins_1.processPluginParser = processPluginParser;
336
+ })(plugins = utils.plugins || (utils.plugins = {})); // namespace utils.plugins
337
+ })(utils || (utils = {})); // namespace utils
338
+ export default utils;
339
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,IAAU,KAAK,CAgXd;AAhXD,WAAU,KAAK;IACb;;;;;;OAMG;IACH,SAAgB,UAAU;QACxB,MAAM,YAAY,GAAkC,IAAI,GAAG,EAAE,CAAC;QAE9D,MAAM,GAAG,GAAG;YACV,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAkC;gBACtD,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,gBAAgB,CAAC,CAAC;oBACrC,MAAM,IAAI,KAAK,EAAE,CAAC;gBACpB,CAAC;gBACD,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAA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AI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBACxC,CAAC;6BAAM,CAAC;4BACN,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;wBAClC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,4CAA4C;QArBxB,6BAAmB,sBAqBxC,CAAA;IACH,CAAC,EAzDgB,OAAO,GAAP,aAAO,KAAP,aAAO,QAyDvB,CAAC,0BAA0B;AAC9B,CAAC,EAhXS,KAAK,KAAL,KAAK,QAgXd,CAAC,kBAAkB;AAEpB,eAAe,KAAK,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "susee-utils",
3
+ "version": "0.0.2",
4
+ "description": "Utilities for suseejs",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.cts",
9
+ "exports": {
10
+ ".": {
11
+ "require": {
12
+ "types": "./dist/index.d.cts",
13
+ "default": "./dist/index.cjs"
14
+ },
15
+ "import": {
16
+ "types": "./dist/index.d.mts",
17
+ "default": "./dist/index.mjs"
18
+ }
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "tsc"
23
+ },
24
+ "keywords": [
25
+ "suseejs"
26
+ ],
27
+ "author": {
28
+ "name": "Pho Thin Mg",
29
+ "email": "phothinmg@disroot.org",
30
+ "url": "https://phothinmg.github.io/"
31
+ },
32
+ "license": "Apache-2.0",
33
+ "bugs": {
34
+ "url": "https://github.com/phothinmg/suseejs/issues"
35
+ },
36
+ "homepage": "https://github.com/phothinmg/suseejs/blob/main/packages/susee-utils/README.md",
37
+ "files": [
38
+ "dist",
39
+ "LICENSE",
40
+ "README.md",
41
+ "package.json"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "dependencies": {
47
+ "susee-tcolor": "file:../susee-tcolor",
48
+ "susee-types": "file:../susee-types",
49
+ "typescript": "^6.0.2"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^25.5.0"
53
+ }
54
+ }