feat(core): Refactor directory reading and module discovery for publishing process
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { logger } from './logging.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
import { PublishModule } from './classes.publishmodule.js';
|
||||
|
||||
@@ -7,8 +8,8 @@ export class TsPublish {
|
||||
constructor() {}
|
||||
|
||||
public async publish (monorepoDirArg: string) {
|
||||
const publishModules = await this.readDirectory(monorepoDirArg);
|
||||
for (const publishModule of publishModules) {
|
||||
const publishModules = await this.getModuleSubDirs(monorepoDirArg);
|
||||
for (const publishModule of Object.keys(publishModules)) {
|
||||
const publishModuleInstance = new PublishModule({
|
||||
monoRepoDir: monorepoDirArg,
|
||||
packageSubFolder: publishModule,
|
||||
@@ -20,9 +21,9 @@ export class TsPublish {
|
||||
}
|
||||
}
|
||||
|
||||
public async readDirectory (dirArg: string) {
|
||||
public async getModuleSubDirs (dirArg: string) {
|
||||
const subDirs = await plugins.smartfile.fs.listFolders(dirArg);
|
||||
const publishModules: string[] = [];
|
||||
const publishModules: {[key: string]: interfaces.ITsPublishJson} = {};
|
||||
for (const subDir of subDirs) {
|
||||
if (!subDir.startsWith('ts')) {
|
||||
continue;
|
||||
@@ -33,7 +34,7 @@ export class TsPublish {
|
||||
continue;
|
||||
}
|
||||
logger.log('info', `found publish module: ${subDir}`);
|
||||
publishModules.push(subDir);
|
||||
publishModules[subDir] = JSON.parse(plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')));
|
||||
}
|
||||
logger.log('ok', `found ${publishModules.length} publish modules`);
|
||||
return publishModules;
|
||||
|
Reference in New Issue
Block a user