@@ -44,18 +44,24 @@ const replacement = `function getTargetConfigurationForTask(task, projectGraph)
44
44
// SPRING_BOOT_DEBUG: Log task details before potential error
45
45
console.log('🎯 SPRING_BOOT_DEBUG: Processing target:', task.target.target, 'for project:', task.target.project);
46
46
47
- if (!projectGraph?.nodes?.[task.target.project]) {
48
- console.log('❌ SPRING_BOOT_DEBUG: Project not found in projectGraph.nodes:', task.target.project);
49
- console.log('❌ SPRING_BOOT_DEBUG: Available projects:', Object.keys(projectGraph?.nodes || {}));
50
- throw new Error(\`Project \${task.target.project} not found in projectGraph.nodes\`);
51
- }
52
-
53
- const project = projectGraph.nodes[task.target.project].data;` ;
47
+ try {
48
+ const project = projectGraph.nodes[task.target.project].data;` ;
54
49
55
50
if ( originalPattern . test ( content ) ) {
56
- // Patch the function
51
+ // Patch the function start
57
52
content = content . replace ( originalPattern , replacement ) ;
58
53
54
+ // Add the closing try-catch block around the return statement
55
+ const returnPattern = / ( \s + r e t u r n p r o j e c t \. t a r g e t s \[ t a s k \. t a r g e t \. t a r g e t \] ; ) \s * } / ;
56
+ content = content . replace ( returnPattern , `$1
57
+ } catch (error) {
58
+ console.log('❌ SPRING_BOOT_DEBUG: Error accessing project data for:', task.target.project);
59
+ // console.log('❌ SPRING_BOOT_DEBUG: Available projects:', Object.keys(projectGraph?.nodes || {}));
60
+ console.log('❌ SPRING_BOOT_DEBUG: Error details:', error.message);
61
+ throw error;
62
+ }
63
+ }` ) ;
64
+
59
65
fs . writeFileSync ( utilsPath , content ) ;
60
66
console . log ( '✅ Successfully patched NX utils.js with debug logging' ) ;
61
67
} else {
@@ -70,13 +76,15 @@ if (originalPattern.test(content)) {
70
76
replacement : `// SPRING_BOOT_DEBUG: Log task details before potential error
71
77
console.log('🎯 SPRING_BOOT_DEBUG: Processing target:', task.target.target, 'for project:', task.target.project);
72
78
73
- if (!projectGraph?.nodes?.[task.target.project]) {
74
- console.log('❌ SPRING_BOOT_DEBUG: Project not found in projectGraph.nodes:', task.target.project);
75
- console.log('❌ SPRING_BOOT_DEBUG: Available projects:', Object.keys(projectGraph?.nodes || {}));
76
- throw new Error(\`Project \${task.target.project} not found in projectGraph.nodes\`);
77
- }
78
-
79
- const project = projectGraph.nodes[task.target.project].data;` ,
79
+ let project;
80
+ try {
81
+ project = projectGraph.nodes[task.target.project].data;
82
+ } catch (error) {
83
+ console.log('❌ SPRING_BOOT_DEBUG: Error accessing project data for:', task.target.project);
84
+ // console.log('❌ SPRING_BOOT_DEBUG: Available projects:', Object.keys(projectGraph?.nodes || {}));
85
+ console.log('❌ SPRING_BOOT_DEBUG: Error details:', error.message);
86
+ throw error;
87
+ }` ,
80
88
name : 'simple pattern'
81
89
} ,
82
90
// Even simpler - just add logging before the line
0 commit comments