11import { fdir } from "fdir" ;
22import { dirname } from "node:path" ;
3+ import { createRequire } from "node:module" ;
34
45import { CWD } from "../constants" ;
56
7+ const require = createRequire ( import . meta. url ) ;
8+
69export type ScannerOptions = {
710 /**
811 * A list of folders to ignore
9- *
10- * @default [".git", "node_modules", "dist", "out"]
1112 */
1213 excludeFolders ?: string [ ] ;
1314 /**
1415 * A list of files to include (following glob matcher)
15- *
16- * @default **\/*\/!(test|stories|*.test|*.stories).?(m){j,t}s?(x)
1716 */
1817 includeFiles ?: string [ ] ;
1918} ;
@@ -29,7 +28,17 @@ export const scan = (options: ScannerOptions = {}) => {
2928 . crawl ( CWD )
3029 . sync ( )
3130 . map ( ( path ) => {
32- return { metadata : path , folder : dirname ( path ) } ;
31+ const metadata = require ( path ) as {
32+ name : string ;
33+ version : string ;
34+ description : string ;
35+ dependencies ?: Record < string , string > ;
36+ devDependencies ?: Record < string , string > ;
37+ peerDependencies ?: Record < string , string > ;
38+ optionalDependencies ?: Record < string , string > ;
39+ } ;
40+
41+ return { metadata, folder : dirname ( path ) } ;
3342 } ) ;
3443
3544 return projects . map ( ( project ) => {
@@ -49,5 +58,3 @@ const DEFAULT_EXCLUDED_FOLDERS = [".git", "node_modules", "dist", "out"];
4958const DEFAULT_INCLUDED_FILES = [
5059 "**/*/!(test|*.test|stories|*.stories).?(m){j,t}s?(x)" , // js|jsx|ts|tsx|cjs|mjs|cjsx|mjsx excluding test-like and story-like files
5160] ;
52-
53- console . log ( scan ( ) ) ;
0 commit comments