@@ -9,7 +9,7 @@ import * as path from 'path';
99import * as yargs from 'yargs' ;
1010import * as inquirer from 'inquirer' ;
1111import * as pkg from '../../package.json' ;
12- import { CONFIG_FILE , PACKAGES_NAME } from './constants' ;
12+ import { CONFIG_FILE , PACKAGES_NAME , PLUGINS_NAME } from './constants' ;
1313import { logFatal } from './log' ;
1414import { PackageJson , GlobalState , ProjectConfig } from './define' ;
1515
@@ -72,13 +72,13 @@ function getPriConfig(rootPath: string) {
7272 return fs . readJsonSync ( configFilePath , { throws : false } ) || { } ;
7373}
7474
75- function collectPackages ( packageRootPath : string , deep = 0 ) {
75+ function collectPackages ( packageRootPath : string , packageDir = PACKAGES_NAME , deep = 0 ) {
7676 // Only support two level packages
7777 if ( deep >= 2 ) {
7878 return ;
7979 }
8080
81- const currentPackagesPath = path . join ( packageRootPath , PACKAGES_NAME ) ;
81+ const currentPackagesPath = path . join ( packageRootPath , packageDir ) ;
8282
8383 if ( fs . existsSync ( currentPackagesPath ) ) {
8484 fs . readdirSync ( currentPackagesPath )
@@ -90,7 +90,7 @@ function collectPackages(packageRootPath: string, deep = 0) {
9090 return true ;
9191 } )
9292 . forEach ( folderName => {
93- const packagePath = path . join ( packageRootPath , PACKAGES_NAME , folderName ) ;
93+ const packagePath = path . join ( packageRootPath , packageDir , folderName ) ;
9494 const packageJson : PackageJson = fs . readJSONSync ( path . join ( packagePath , 'package.json' ) , { throws : false } ) ;
9595
9696 const config = fs . readJsonSync ( path . join ( packagePath , CONFIG_FILE ) , { throws : false } ) || { } ;
@@ -102,16 +102,23 @@ function collectPackages(packageRootPath: string, deep = 0) {
102102 config,
103103 } ;
104104
105- globalState . packages . push ( eachPackage ) ;
105+ if ( packageDir === PLUGINS_NAME ) {
106+ globalState . plugins . push ( eachPackage ) ;
107+ } else {
108+ globalState . packages . push ( eachPackage ) ;
109+ }
106110
107111 // find nested packages
108- collectPackages ( eachPackage . rootPath , deep + 1 ) ;
112+ if ( packageDir !== PLUGINS_NAME ) {
113+ collectPackages ( eachPackage . rootPath , packageDir , deep + 1 ) ;
114+ }
109115 } ) ;
110116 }
111117}
112118
113119async function initPackages ( projectRootPath : string , preSelectPackage : string ) {
114120 collectPackages ( projectRootPath ) ;
121+ collectPackages ( projectRootPath , PLUGINS_NAME ) ;
115122
116123 if ( globalState . packages . length > 0 ) {
117124 if ( ! preSelectPackage ) {
0 commit comments