devbonzai 2.0.1 → 2.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/cli.js +36 -8
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -457,10 +457,10 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
457
457
|
// Helper function to extract methods from a class body
|
|
458
458
|
const extractClassMethods = (classNode, className) => {
|
|
459
459
|
const methods = [];
|
|
460
|
-
if (classNode.body && classNode.body.body) {
|
|
460
|
+
if (classNode.body && classNode.body.body && Array.isArray(classNode.body.body)) {
|
|
461
461
|
for (const member of classNode.body.body) {
|
|
462
462
|
// Handle MethodDefinition (regular methods, constructors, getters, setters, static methods)
|
|
463
|
-
if (member.type === 'MethodDefinition' && member.key) {
|
|
463
|
+
if (member && member.type === 'MethodDefinition' && member.key) {
|
|
464
464
|
let methodName;
|
|
465
465
|
if (member.key.type === 'Identifier') {
|
|
466
466
|
methodName = member.key.name;
|
|
@@ -476,6 +476,19 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
476
476
|
const kind = member.kind || 'method';
|
|
477
477
|
const isStatic = member.static || false;
|
|
478
478
|
|
|
479
|
+
// For getters and setters, include the kind in the method name to distinguish them
|
|
480
|
+
// e.g., "value" getter vs "value" setter -> "get value" and "set value"
|
|
481
|
+
let fullMethodName = methodName;
|
|
482
|
+
if (kind === 'get') {
|
|
483
|
+
fullMethodName = 'get ' + methodName;
|
|
484
|
+
} else if (kind === 'set') {
|
|
485
|
+
fullMethodName = 'set ' + methodName;
|
|
486
|
+
} else if (kind === 'constructor') {
|
|
487
|
+
fullMethodName = 'constructor';
|
|
488
|
+
} else if (isStatic) {
|
|
489
|
+
fullMethodName = 'static ' + methodName;
|
|
490
|
+
}
|
|
491
|
+
|
|
479
492
|
methods.push({
|
|
480
493
|
name: className + '.' + methodName,
|
|
481
494
|
content: getCode(member),
|
|
@@ -692,10 +705,10 @@ function extractVueFunctions(filePath) {
|
|
|
692
705
|
// Helper function to extract methods from a class body
|
|
693
706
|
const extractClassMethods = (classNode, className) => {
|
|
694
707
|
const methods = [];
|
|
695
|
-
if (classNode.body && classNode.body.body) {
|
|
708
|
+
if (classNode.body && classNode.body.body && Array.isArray(classNode.body.body)) {
|
|
696
709
|
for (const member of classNode.body.body) {
|
|
697
710
|
// Handle MethodDefinition (regular methods, constructors, getters, setters, static methods)
|
|
698
|
-
if (member.type === 'MethodDefinition' && member.key) {
|
|
711
|
+
if (member && member.type === 'MethodDefinition' && member.key) {
|
|
699
712
|
let methodName;
|
|
700
713
|
if (member.key.type === 'Identifier') {
|
|
701
714
|
methodName = member.key.name;
|
|
@@ -711,6 +724,19 @@ function extractVueFunctions(filePath) {
|
|
|
711
724
|
const kind = member.kind || 'method';
|
|
712
725
|
const isStatic = member.static || false;
|
|
713
726
|
|
|
727
|
+
// For getters and setters, include the kind in the method name to distinguish them
|
|
728
|
+
// e.g., "value" getter vs "value" setter -> "get value" and "set value"
|
|
729
|
+
let fullMethodName = methodName;
|
|
730
|
+
if (kind === 'get') {
|
|
731
|
+
fullMethodName = 'get ' + methodName;
|
|
732
|
+
} else if (kind === 'set') {
|
|
733
|
+
fullMethodName = 'set ' + methodName;
|
|
734
|
+
} else if (kind === 'constructor') {
|
|
735
|
+
fullMethodName = 'constructor';
|
|
736
|
+
} else if (isStatic) {
|
|
737
|
+
fullMethodName = 'static ' + methodName;
|
|
738
|
+
}
|
|
739
|
+
|
|
714
740
|
methods.push({
|
|
715
741
|
name: className + '.' + methodName,
|
|
716
742
|
content: getCode(member),
|
|
@@ -881,10 +907,12 @@ function listAllFiles(dir, base = '', ignorePatterns = null) {
|
|
|
881
907
|
results.push(classFilePath);
|
|
882
908
|
|
|
883
909
|
// Add methods nested under the class: ClassName.methodName
|
|
884
|
-
|
|
885
|
-
const
|
|
886
|
-
|
|
887
|
-
|
|
910
|
+
if (cls.methods && cls.methods.length > 0) {
|
|
911
|
+
for (const method of cls.methods) {
|
|
912
|
+
const methodFileName = method.name + '.method';
|
|
913
|
+
const methodFilePath = path.join(classFilePath, methodFileName).replace(/\\\\/g, '/');
|
|
914
|
+
results.push(methodFilePath);
|
|
915
|
+
}
|
|
888
916
|
}
|
|
889
917
|
}
|
|
890
918
|
};
|