@@ -7,21 +7,25 @@ const libs = path.join(root, "lib");
77const clients = path . join ( root , "clients" ) ;
88
99/**
10- * Throw and Error if any deprecated package is not marked private.
10+ * Throw and Error if any reserved package is not marked private.
1111 */
1212{
1313 const excluded = [ ] ;
1414
15- const deprecatedPackages = path . join ( root , "deprecated" , "packages" ) ;
16- for ( const folder of fs . readdirSync ( deprecatedPackages ) ) {
17- const pkgJson = require ( path . join ( deprecatedPackages , folder , "package.json" ) ) ;
15+ const reservedPackages = path . join ( root , "reserved" , "packages" ) ;
16+ for ( const folder of fs . readdirSync ( reservedPackages ) ) {
17+ const pkgJsonPath = path . join ( reservedPackages , folder , "package.json" ) ;
18+ if ( ! fs . existsSync ( pkgJsonPath ) ) {
19+ continue ;
20+ }
21+ const pkgJson = require ( path . join ( reservedPackages , folder , "package.json" ) ) ;
1822
1923 if ( excluded . includes ( pkgJson . name ) ) {
2024 continue ;
2125 }
2226
2327 if ( pkgJson . private !== true ) {
24- throw new Error ( "package in deprecated folder is not marked private:" , folder ) ;
28+ throw new Error ( "package in reserved folder is not marked private:" , folder ) ;
2529 } else {
2630 }
2731 }
@@ -31,9 +35,19 @@ const clients = path.join(root, "clients");
3135 * Analyze package dependency graph.
3236 */
3337{
34- const packagesData = fs . readdirSync ( packages ) . map ( ( pkg ) => require ( path . join ( packages , pkg , "package.json" ) ) ) ;
35- const libsData = fs . readdirSync ( libs ) . map ( ( pkg ) => require ( path . join ( libs , pkg , "package.json" ) ) ) ;
36- const clientsData = fs . readdirSync ( clients ) . map ( ( pkg ) => require ( path . join ( clients , pkg , "package.json" ) ) ) ;
38+ const hasPkgJson = ( subfolder , pkg ) => fs . existsSync ( path . join ( subfolder , pkg , "package.json" ) ) ;
39+ const packagesData = fs
40+ . readdirSync ( packages )
41+ . filter ( hasPkgJson . bind ( null , "packages" ) )
42+ . map ( ( pkg ) => require ( path . join ( packages , pkg , "package.json" ) ) ) ;
43+ const libsData = fs
44+ . readdirSync ( libs )
45+ . filter ( hasPkgJson . bind ( null , "libs" ) )
46+ . map ( ( pkg ) => require ( path . join ( libs , pkg , "package.json" ) ) ) ;
47+ const clientsData = fs
48+ . readdirSync ( clients )
49+ . filter ( hasPkgJson . bind ( null , "clients" ) )
50+ . map ( ( pkg ) => require ( path . join ( clients , pkg , "package.json" ) ) ) ;
3751
3852 const allPackages = [ ...packagesData , ...libsData , ...clientsData ] ;
3953
0 commit comments