devbonzai 1.8.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +128 -65
- package/package.json +3 -4
package/cli.js
CHANGED
|
@@ -454,19 +454,28 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
//
|
|
458
|
-
|
|
459
|
-
if (node.type === 'ClassDeclaration' && node.id && parentType !== 'ExportNamedDeclaration') {
|
|
460
|
-
const className = node.id.name;
|
|
457
|
+
// Helper function to extract methods from a class body
|
|
458
|
+
const extractClassMethods = (classNode, className) => {
|
|
461
459
|
const methods = [];
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
for (const member of node.body.body) {
|
|
460
|
+
if (classNode.body && classNode.body.body) {
|
|
461
|
+
for (const member of classNode.body.body) {
|
|
462
|
+
// Handle MethodDefinition (regular methods, constructors, getters, setters, static methods)
|
|
466
463
|
if (member.type === 'MethodDefinition' && member.key) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
464
|
+
let methodName;
|
|
465
|
+
if (member.key.type === 'Identifier') {
|
|
466
|
+
methodName = member.key.name;
|
|
467
|
+
} else if (member.key.type === 'PrivateName') {
|
|
468
|
+
methodName = '#' + member.key.id.name;
|
|
469
|
+
} else if (member.key.type === 'StringLiteral' || member.key.type === 'NumericLiteral') {
|
|
470
|
+
methodName = String(member.key.value);
|
|
471
|
+
} else {
|
|
472
|
+
methodName = String(member.key.value || member.key.name || 'unknown');
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// Include kind (constructor, get, set, method) in the name for clarity
|
|
476
|
+
const kind = member.kind || 'method';
|
|
477
|
+
const isStatic = member.static || false;
|
|
478
|
+
|
|
470
479
|
methods.push({
|
|
471
480
|
name: className + '.' + methodName,
|
|
472
481
|
content: getCode(member),
|
|
@@ -474,11 +483,22 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
474
483
|
endLine: member.loc ? member.loc.end.line : 0,
|
|
475
484
|
isMethod: true,
|
|
476
485
|
className: className,
|
|
477
|
-
methodName: methodName
|
|
486
|
+
methodName: methodName,
|
|
487
|
+
kind: kind,
|
|
488
|
+
static: isStatic
|
|
478
489
|
});
|
|
479
490
|
}
|
|
480
491
|
}
|
|
481
492
|
}
|
|
493
|
+
return methods;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
// Class declarations: class User { ... }
|
|
497
|
+
// Skip if inside ExportNamedDeclaration or ExportDefaultDeclaration (will be handled below)
|
|
498
|
+
if (node.type === 'ClassDeclaration' && node.id &&
|
|
499
|
+
parentType !== 'ExportNamedDeclaration' && parentType !== 'ExportDefaultDeclaration') {
|
|
500
|
+
const className = node.id.name;
|
|
501
|
+
const methods = extractClassMethods(node, className);
|
|
482
502
|
|
|
483
503
|
classes.push({
|
|
484
504
|
name: className,
|
|
@@ -489,7 +509,7 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
489
509
|
});
|
|
490
510
|
}
|
|
491
511
|
|
|
492
|
-
// Export declarations: export function, export
|
|
512
|
+
// Export declarations: export function, export class
|
|
493
513
|
if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
494
514
|
if (node.declaration.type === 'FunctionDeclaration' && node.declaration.id) {
|
|
495
515
|
functions.push({
|
|
@@ -503,26 +523,7 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
503
523
|
visitedNodes.add(node.declaration);
|
|
504
524
|
} else if (node.declaration.type === 'ClassDeclaration' && node.declaration.id) {
|
|
505
525
|
const className = node.declaration.id.name;
|
|
506
|
-
const methods =
|
|
507
|
-
|
|
508
|
-
if (node.declaration.body && node.declaration.body.body) {
|
|
509
|
-
for (const member of node.declaration.body.body) {
|
|
510
|
-
if (member.type === 'MethodDefinition' && member.key) {
|
|
511
|
-
const methodName = member.key.type === 'Identifier' ? member.key.name :
|
|
512
|
-
member.key.type === 'PrivateName' ? '#' + member.key.id.name :
|
|
513
|
-
String(member.key.value || member.key.name);
|
|
514
|
-
methods.push({
|
|
515
|
-
name: className + '.' + methodName,
|
|
516
|
-
content: getCode(member),
|
|
517
|
-
startLine: member.loc ? member.loc.start.line : 0,
|
|
518
|
-
endLine: member.loc ? member.loc.end.line : 0,
|
|
519
|
-
isMethod: true,
|
|
520
|
-
className: className,
|
|
521
|
-
methodName: methodName
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
+
const methods = extractClassMethods(node.declaration, className);
|
|
526
527
|
|
|
527
528
|
classes.push({
|
|
528
529
|
name: className,
|
|
@@ -537,6 +538,36 @@ function extractJavaScriptFunctions(filePath) {
|
|
|
537
538
|
}
|
|
538
539
|
}
|
|
539
540
|
|
|
541
|
+
// Export default declarations: export default class
|
|
542
|
+
if (node.type === 'ExportDefaultDeclaration' && node.declaration) {
|
|
543
|
+
if (node.declaration.type === 'ClassDeclaration' && node.declaration.id) {
|
|
544
|
+
const className = node.declaration.id.name;
|
|
545
|
+
const methods = extractClassMethods(node.declaration, className);
|
|
546
|
+
|
|
547
|
+
classes.push({
|
|
548
|
+
name: className,
|
|
549
|
+
content: getCode(node.declaration),
|
|
550
|
+
methods: methods,
|
|
551
|
+
startLine: node.declaration.loc ? node.declaration.loc.start.line : 0,
|
|
552
|
+
endLine: node.declaration.loc ? node.declaration.loc.end.line : 0,
|
|
553
|
+
isExported: true,
|
|
554
|
+
isDefaultExport: true
|
|
555
|
+
});
|
|
556
|
+
// Mark as visited to avoid duplicate processing
|
|
557
|
+
visitedNodes.add(node.declaration);
|
|
558
|
+
} else if (node.declaration.type === 'FunctionDeclaration' && node.declaration.id) {
|
|
559
|
+
functions.push({
|
|
560
|
+
name: node.declaration.id.name,
|
|
561
|
+
content: getCode(node.declaration),
|
|
562
|
+
startLine: node.declaration.loc ? node.declaration.loc.start.line : 0,
|
|
563
|
+
endLine: node.declaration.loc ? node.declaration.loc.end.line : 0,
|
|
564
|
+
isExported: true,
|
|
565
|
+
isDefaultExport: true
|
|
566
|
+
});
|
|
567
|
+
visitedNodes.add(node.declaration);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
540
571
|
// Recursively traverse children
|
|
541
572
|
for (const key in node) {
|
|
542
573
|
if (key === 'parent' || key === 'leadingComments' || key === 'trailingComments') continue;
|
|
@@ -658,18 +689,28 @@ function extractVueFunctions(filePath) {
|
|
|
658
689
|
});
|
|
659
690
|
}
|
|
660
691
|
|
|
661
|
-
//
|
|
662
|
-
|
|
663
|
-
if (node.type === 'ClassDeclaration' && node.id && parentType !== 'ExportNamedDeclaration') {
|
|
664
|
-
const className = node.id.name;
|
|
692
|
+
// Helper function to extract methods from a class body
|
|
693
|
+
const extractClassMethods = (classNode, className) => {
|
|
665
694
|
const methods = [];
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
695
|
+
if (classNode.body && classNode.body.body) {
|
|
696
|
+
for (const member of classNode.body.body) {
|
|
697
|
+
// Handle MethodDefinition (regular methods, constructors, getters, setters, static methods)
|
|
669
698
|
if (member.type === 'MethodDefinition' && member.key) {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
699
|
+
let methodName;
|
|
700
|
+
if (member.key.type === 'Identifier') {
|
|
701
|
+
methodName = member.key.name;
|
|
702
|
+
} else if (member.key.type === 'PrivateName') {
|
|
703
|
+
methodName = '#' + member.key.id.name;
|
|
704
|
+
} else if (member.key.type === 'StringLiteral' || member.key.type === 'NumericLiteral') {
|
|
705
|
+
methodName = String(member.key.value);
|
|
706
|
+
} else {
|
|
707
|
+
methodName = String(member.key.value || member.key.name || 'unknown');
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// Include kind (constructor, get, set, method) in the name for clarity
|
|
711
|
+
const kind = member.kind || 'method';
|
|
712
|
+
const isStatic = member.static || false;
|
|
713
|
+
|
|
673
714
|
methods.push({
|
|
674
715
|
name: className + '.' + methodName,
|
|
675
716
|
content: getCode(member),
|
|
@@ -677,11 +718,22 @@ function extractVueFunctions(filePath) {
|
|
|
677
718
|
endLine: member.loc ? member.loc.end.line : 0,
|
|
678
719
|
isMethod: true,
|
|
679
720
|
className: className,
|
|
680
|
-
methodName: methodName
|
|
721
|
+
methodName: methodName,
|
|
722
|
+
kind: kind,
|
|
723
|
+
static: isStatic
|
|
681
724
|
});
|
|
682
725
|
}
|
|
683
726
|
}
|
|
684
727
|
}
|
|
728
|
+
return methods;
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// Class declarations: class User { ... }
|
|
732
|
+
// Skip if inside ExportNamedDeclaration or ExportDefaultDeclaration (will be handled below)
|
|
733
|
+
if (node.type === 'ClassDeclaration' && node.id &&
|
|
734
|
+
parentType !== 'ExportNamedDeclaration' && parentType !== 'ExportDefaultDeclaration') {
|
|
735
|
+
const className = node.id.name;
|
|
736
|
+
const methods = extractClassMethods(node, className);
|
|
685
737
|
|
|
686
738
|
classes.push({
|
|
687
739
|
name: className,
|
|
@@ -692,7 +744,7 @@ function extractVueFunctions(filePath) {
|
|
|
692
744
|
});
|
|
693
745
|
}
|
|
694
746
|
|
|
695
|
-
// Export declarations: export function, export
|
|
747
|
+
// Export declarations: export function, export class
|
|
696
748
|
if (node.type === 'ExportNamedDeclaration' && node.declaration) {
|
|
697
749
|
if (node.declaration.type === 'FunctionDeclaration' && node.declaration.id) {
|
|
698
750
|
functions.push({
|
|
@@ -706,26 +758,7 @@ function extractVueFunctions(filePath) {
|
|
|
706
758
|
visitedNodes.add(node.declaration);
|
|
707
759
|
} else if (node.declaration.type === 'ClassDeclaration' && node.declaration.id) {
|
|
708
760
|
const className = node.declaration.id.name;
|
|
709
|
-
const methods =
|
|
710
|
-
|
|
711
|
-
if (node.declaration.body && node.declaration.body.body) {
|
|
712
|
-
for (const member of node.declaration.body.body) {
|
|
713
|
-
if (member.type === 'MethodDefinition' && member.key) {
|
|
714
|
-
const methodName = member.key.type === 'Identifier' ? member.key.name :
|
|
715
|
-
member.key.type === 'PrivateName' ? '#' + member.key.id.name :
|
|
716
|
-
String(member.key.value || member.key.name);
|
|
717
|
-
methods.push({
|
|
718
|
-
name: className + '.' + methodName,
|
|
719
|
-
content: getCode(member),
|
|
720
|
-
startLine: member.loc ? member.loc.start.line : 0,
|
|
721
|
-
endLine: member.loc ? member.loc.end.line : 0,
|
|
722
|
-
isMethod: true,
|
|
723
|
-
className: className,
|
|
724
|
-
methodName: methodName
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
}
|
|
761
|
+
const methods = extractClassMethods(node.declaration, className);
|
|
729
762
|
|
|
730
763
|
classes.push({
|
|
731
764
|
name: className,
|
|
@@ -740,6 +773,36 @@ function extractVueFunctions(filePath) {
|
|
|
740
773
|
}
|
|
741
774
|
}
|
|
742
775
|
|
|
776
|
+
// Export default declarations: export default class
|
|
777
|
+
if (node.type === 'ExportDefaultDeclaration' && node.declaration) {
|
|
778
|
+
if (node.declaration.type === 'ClassDeclaration' && node.declaration.id) {
|
|
779
|
+
const className = node.declaration.id.name;
|
|
780
|
+
const methods = extractClassMethods(node.declaration, className);
|
|
781
|
+
|
|
782
|
+
classes.push({
|
|
783
|
+
name: className,
|
|
784
|
+
content: getCode(node.declaration),
|
|
785
|
+
methods: methods,
|
|
786
|
+
startLine: node.declaration.loc ? node.declaration.loc.start.line : 0,
|
|
787
|
+
endLine: node.declaration.loc ? node.declaration.loc.end.line : 0,
|
|
788
|
+
isExported: true,
|
|
789
|
+
isDefaultExport: true
|
|
790
|
+
});
|
|
791
|
+
// Mark as visited to avoid duplicate processing
|
|
792
|
+
visitedNodes.add(node.declaration);
|
|
793
|
+
} else if (node.declaration.type === 'FunctionDeclaration' && node.declaration.id) {
|
|
794
|
+
functions.push({
|
|
795
|
+
name: node.declaration.id.name,
|
|
796
|
+
content: getCode(node.declaration),
|
|
797
|
+
startLine: node.declaration.loc ? node.declaration.loc.start.line : 0,
|
|
798
|
+
endLine: node.declaration.loc ? node.declaration.loc.end.line : 0,
|
|
799
|
+
isExported: true,
|
|
800
|
+
isDefaultExport: true
|
|
801
|
+
});
|
|
802
|
+
visitedNodes.add(node.declaration);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
743
806
|
// Recursively traverse children
|
|
744
807
|
for (const key in node) {
|
|
745
808
|
if (key === 'parent' || key === 'leadingComments' || key === 'trailingComments') continue;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devbonzai",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Quickly set up a local file server in any repository for browser-based file access",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"
|
|
7
|
+
"devchart": "./cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"express": "^4.18.2",
|
|
22
22
|
"cors": "^2.8.5",
|
|
23
23
|
"body-parser": "^1.20.2",
|
|
24
|
-
"raw-body": "^2.5.2"
|
|
25
|
-
"@babel/parser": "^7.23.0"
|
|
24
|
+
"raw-body": "^2.5.2"
|
|
26
25
|
}
|
|
27
26
|
}
|