From 78c73ee71330ee4a7e87afea032adc61fce35af2 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Tue, 5 Nov 2024 00:47:16 +0100 Subject: [PATCH] fix(classes.tspublish): Refactor getModuleSubDirs method to streamline name validation for publish modules --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/classes.tspublish.ts | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index b03e2d4..ff0a8ee 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-11-05 - 1.7.4 - fix(classes.tspublish) +Refactor getModuleSubDirs method to streamline name validation for publish modules + +- Moved the check for the presence of the 'name' field in tspublish.json from getModuleSubDirs to the publish method. +- Added log warning and continue flow if 'name' is not found during the publish process. + ## 2024-11-05 - 1.7.3 - fix(TsPublish) Add validation for tspublish.json name field diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 67a0447..739bfe3 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tspublish', - version: '1.7.3', + version: '1.7.4', description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.' } diff --git a/ts/classes.tspublish.ts b/ts/classes.tspublish.ts index 18649b2..ed80a3e 100644 --- a/ts/classes.tspublish.ts +++ b/ts/classes.tspublish.ts @@ -17,6 +17,14 @@ export class TsPublish { ); } for (const publishModule of Object.keys(publishModules)) { + // lets check wether there is a name + const tspublishJson = JSON.parse( + plugins.smartfile.fs.toStringSync(plugins.path.join(publishModule, 'tspublish.json')), + ); + if (!tspublishJson.name) { + logger.log('warn', `no name found in tspublish.json for ${publishModule}. Skipping...`); + continue; + } const publishModuleInstance = new PublishModule({ monoRepoDir: monorepoDirArg, packageSubFolder: publishModule, @@ -41,21 +49,14 @@ export class TsPublish { continue; } - // lets check wether there is a name - const tspublishJson = JSON.parse( - plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')), - ); - if (!tspublishJson.name) { - logger.log('warn', `no name found in tspublish.json for ${subDir}`); - continue; - } - logger.log('info', `found publish module: ${subDir}`); publishModules[subDir] = JSON.parse( plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')), ); } logger.log('ok', `found ${publishModules.length} publish modules`); + logger.log('info', `Ordering publish modules...`); + return publishModules; } }