@@ -26,21 +26,22 @@ async function fileExists(filePath) {
2626 * Main validation function.
2727 */
2828async function validate ( ) {
29- getDefaultLogger ( ) . log ( '' )
30- getDefaultLogger ( ) . log ( '=' . repeat ( 60 ) )
31- getDefaultLogger ( ) . log ( `${ colors . blue ( 'CLI with Sentry Package Validation' ) } ` )
32- getDefaultLogger ( ) . log ( '=' . repeat ( 60 ) )
33- getDefaultLogger ( ) . log ( '' )
29+ const logger = getDefaultLogger ( )
30+ logger . log ( '' )
31+ logger . log ( '=' . repeat ( 60 ) )
32+ logger . log ( `${ colors . blue ( 'CLI with Sentry Package Validation' ) } ` )
33+ logger . log ( '=' . repeat ( 60 ) )
34+ logger . log ( '' )
3435
3536 const errors = [ ]
3637
3738 // Check package.json exists and validate Sentry configuration.
38- getDefaultLogger ( ) . info ( 'Checking package.json...' )
39+ logger . info ( 'Checking package.json...' )
3940 const pkgPath = path . join ( packageRoot , 'package.json' )
4041 if ( ! ( await fileExists ( pkgPath ) ) ) {
4142 errors . push ( 'package.json does not exist' )
4243 } else {
43- getDefaultLogger ( ) . success ( 'package.json exists' )
44+ logger . success ( 'package.json exists' )
4445
4546 // Validate package.json configuration.
4647 const pkg = JSON . parse ( await fs . readFile ( pkgPath , 'utf-8' ) )
@@ -49,7 +50,7 @@ async function validate() {
4950 if ( ! pkg . dependencies ?. [ '@sentry/node' ] ) {
5051 errors . push ( 'package.json missing @sentry/node in dependencies' )
5152 } else {
52- getDefaultLogger ( ) . success ( '@sentry/node is in dependencies' )
53+ logger . success ( '@sentry/node is in dependencies' )
5354 }
5455
5556 // Validate files array.
@@ -67,99 +68,99 @@ async function validate() {
6768 }
6869 }
6970 if ( errors . length === 0 ) {
70- getDefaultLogger ( ) . success ( 'package.json files array is correct' )
71+ logger . success ( 'package.json files array is correct' )
7172 }
7273 }
7374
7475 // Check root files exist (LICENSE, CHANGELOG.md).
7576 const rootFiles = [ 'LICENSE' , 'CHANGELOG.md' ]
7677 for ( const file of rootFiles ) {
77- getDefaultLogger ( ) . info ( `Checking ${ file } ...` )
78+ logger . info ( `Checking ${ file } ...` )
7879 const filePath = path . join ( packageRoot , file )
7980 if ( ! ( await fileExists ( filePath ) ) ) {
8081 errors . push ( `${ file } does not exist` )
8182 } else {
82- getDefaultLogger ( ) . success ( `${ file } exists` )
83+ logger . success ( `${ file } exists` )
8384 }
8485 }
8586
8687 // Check dist files exist and validate Sentry integration.
8788 const distFiles = [ 'index.js' , 'cli.js.bz' , 'shadow-npm-inject.js' ]
8889 for ( const file of distFiles ) {
89- getDefaultLogger ( ) . info ( `Checking dist/${ file } ...` )
90+ logger . info ( `Checking dist/${ file } ...` )
9091 const filePath = path . join ( packageRoot , 'dist' , file )
9192 if ( ! ( await fileExists ( filePath ) ) ) {
9293 errors . push ( `dist/${ file } does not exist` )
9394 } else {
94- getDefaultLogger ( ) . success ( `dist/${ file } exists` )
95+ logger . success ( `dist/${ file } exists` )
9596 }
9697 }
9798
9899 // Verify Sentry is referenced in the build (check for @sentry/node require).
99- getDefaultLogger ( ) . info ( 'Checking for Sentry integration in build...' )
100+ logger . info ( 'Checking for Sentry integration in build...' )
100101 const buildPath = path . join ( packageRoot , 'build' , 'cli.js' )
101102 if ( await fileExists ( buildPath ) ) {
102103 const buildContent = await fs . readFile ( buildPath , 'utf-8' )
103104 if ( ! buildContent . includes ( '@sentry/node' ) ) {
104105 errors . push ( 'Sentry integration not found in build/cli.js' )
105106 } else {
106- getDefaultLogger ( ) . success ( 'Sentry integration found in build' )
107+ logger . success ( 'Sentry integration found in build' )
107108 }
108109 } else {
109110 errors . push ( 'build/cli.js does not exist (required for Sentry validation)' )
110111 }
111112
112113 // Check data directory exists.
113- getDefaultLogger ( ) . info ( 'Checking data directory...' )
114+ logger . info ( 'Checking data directory...' )
114115 const dataPath = path . join ( packageRoot , 'data' )
115116 if ( ! ( await fileExists ( dataPath ) ) ) {
116117 errors . push ( 'data directory does not exist' )
117118 } else {
118- getDefaultLogger ( ) . success ( 'data directory exists' )
119+ logger . success ( 'data directory exists' )
119120
120121 // Check data files.
121122 const dataFiles = [
122123 'alert-translations.json' ,
123124 'command-api-requirements.json' ,
124125 ]
125126 for ( const file of dataFiles ) {
126- getDefaultLogger ( ) . info ( `Checking data/${ file } ...` )
127+ logger . info ( `Checking data/${ file } ...` )
127128 const filePath = path . join ( dataPath , file )
128129 if ( ! ( await fileExists ( filePath ) ) ) {
129130 errors . push ( `data/${ file } does not exist` )
130131 } else {
131- getDefaultLogger ( ) . success ( `data/${ file } exists` )
132+ logger . success ( `data/${ file } exists` )
132133 }
133134 }
134135 }
135136
136137 // Print summary.
137- getDefaultLogger ( ) . log ( '' )
138- getDefaultLogger ( ) . log ( '=' . repeat ( 60 ) )
139- getDefaultLogger ( ) . log ( `${ colors . blue ( 'Validation Summary' ) } ` )
140- getDefaultLogger ( ) . log ( '=' . repeat ( 60 ) )
141- getDefaultLogger ( ) . log ( '' )
138+ logger . log ( '' )
139+ logger . log ( '=' . repeat ( 60 ) )
140+ logger . log ( `${ colors . blue ( 'Validation Summary' ) } ` )
141+ logger . log ( '=' . repeat ( 60 ) )
142+ logger . log ( '' )
142143
143144 if ( errors . length > 0 ) {
144- getDefaultLogger ( ) . log ( `${ colors . red ( 'Errors:' ) } ` )
145+ logger . log ( `${ colors . red ( 'Errors:' ) } ` )
145146 for ( const err of errors ) {
146- getDefaultLogger ( ) . fail ( ` ${ err } ` )
147+ logger . fail ( ` ${ err } ` )
147148 }
148- getDefaultLogger ( ) . log ( '' )
149- getDefaultLogger ( ) . fail ( 'Package validation FAILED' )
150- getDefaultLogger ( ) . log ( '' )
149+ logger . log ( '' )
150+ logger . fail ( 'Package validation FAILED' )
151+ logger . log ( '' )
151152 process . exit ( 1 )
152153 }
153154
154- getDefaultLogger ( ) . success ( 'Package validation PASSED' )
155- getDefaultLogger ( ) . log ( '' )
155+ logger . success ( 'Package validation PASSED' )
156+ logger . log ( '' )
156157 process . exit ( 0 )
157158}
158159
159160// Run validation.
160161validate ( ) . catch ( e => {
161- getDefaultLogger ( ) . error ( '' )
162- getDefaultLogger ( ) . fail ( `Unexpected error: ${ e . message } ` )
163- getDefaultLogger ( ) . error ( '' )
162+ logger . error ( '' )
163+ logger . fail ( `Unexpected error: ${ e . message } ` )
164+ logger . error ( '' )
164165 process . exit ( 1 )
165166} )
0 commit comments