@@ -23,6 +23,12 @@ import { snakeToSlug } from './helpers'
2323
2424type Scope = '@scaleway' | '@scaleway-internal'
2525
26+ interface SdkPackageJson {
27+ dependencies ? : Record < string , string >
28+ devDependencies ? : Record < string , string >
29+ [ key : string ] : unknown
30+ }
31+
2632const options : ParseArgsConfig [ 'options' ] = {
2733 'dry-run' : { type : 'boolean' , default : false } ,
2834 src : { type : 'string' , default : 'packages_generated' } ,
@@ -78,7 +84,7 @@ function safeReadJson(path: string): unknown {
7884}
7985
8086function writeJsonIfChanged ( path : string , data : unknown ) {
81- const newContent = JSON . stringify ( data , null , 2 ) + '\n'
87+ const newContent = ` ${ JSON . stringify ( data , null , 2 ) } \n`
8288 const oldContent = existsSync ( path ) ? readFileSync ( path , 'utf8' ) : ''
8389 if ( oldContent !== newContent ) {
8490 if ( DRY_RUN ) {
@@ -95,8 +101,9 @@ function writeJsonIfChanged(path: string, data: unknown) {
95101function walkHasGenFiles ( root : string ) : boolean {
96102 if ( ! existsSync ( root ) ) return false
97103 const stack = [ root ]
98- while ( stack . length ) {
99- const p = stack . pop ( ) !
104+ while ( stack . length > 0 ) {
105+ const p = stack . pop ( )
106+ if ( ! p ) break
100107 const st = statSync ( p )
101108 if ( st . isDirectory ( ) ) {
102109 for ( const name of readdirSync ( p ) ) stack . push ( join ( p , name ) )
@@ -162,7 +169,7 @@ function detectPackageScope(sdkPackageJsonPath: string): Scope {
162169 warn ( '⚠️ SDK package.json not found, using @scaleway scope' )
163170 return '@scaleway'
164171 }
165- const sdkPackage = safeReadJson ( sdkPackageJsonPath ) as any
172+ const sdkPackage = safeReadJson ( sdkPackageJsonPath ) as SdkPackageJson
166173 const deps : Record < string , string > = sdkPackage ?. dependencies ?? { }
167174 const hasInternal = Object . keys ( deps ) . some ( k =>
168175 k . startsWith ( '@scaleway-internal/sdk-' ) ,
@@ -180,7 +187,7 @@ function updateSdkPackageJson(
180187 return { added : [ ] }
181188 }
182189
183- const sdkPackage = safeReadJson ( sdkPackageJsonPath ) as any
190+ const sdkPackage = safeReadJson ( sdkPackageJsonPath ) as SdkPackageJson
184191 sdkPackage . dependencies = sdkPackage . dependencies ?? { }
185192 sdkPackage . devDependencies = sdkPackage . devDependencies ?? { }
186193
0 commit comments