From 023aea249490f081c49fa07f1cbf4312ec58e635 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Tue, 5 Nov 2024 00:41:46 +0100 Subject: [PATCH] fix(TsPublish): Add validation for tspublish.json name field --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/classes.tspublish.ts | 10 ++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index c5866c0..b03e2d4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-11-05 - 1.7.3 - fix(TsPublish) +Add validation for tspublish.json name field + +- Ensure that the tspublish.json file contains a valid name field before processing. +- Log a warning message if the name is not found in tspublish.json. + ## 2024-11-05 - 1.7.2 - fix(project) Fixed minor formatting issues and improved code consistency. diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 18093cf..67a0447 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.2', + version: '1.7.3', 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 43f1293..18649b2 100644 --- a/ts/classes.tspublish.ts +++ b/ts/classes.tspublish.ts @@ -40,6 +40,16 @@ export class TsPublish { if (!hasPublishJson) { 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')),