fix(classes.tspublish): Refactor getModuleSubDirs method to streamline name validation for publish modules

This commit is contained in:
Philipp Kunz 2024-11-05 00:47:16 +01:00
parent 5b768288c5
commit 78c73ee713
3 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,11 @@
# Changelog # 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) ## 2024-11-05 - 1.7.3 - fix(TsPublish)
Add validation for tspublish.json name field Add validation for tspublish.json name field

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tspublish', 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.' description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.'
} }

View File

@ -17,6 +17,14 @@ export class TsPublish {
); );
} }
for (const publishModule of Object.keys(publishModules)) { 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({ const publishModuleInstance = new PublishModule({
monoRepoDir: monorepoDirArg, monoRepoDir: monorepoDirArg,
packageSubFolder: publishModule, packageSubFolder: publishModule,
@ -41,21 +49,14 @@ export class TsPublish {
continue; 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}`); logger.log('info', `found publish module: ${subDir}`);
publishModules[subDir] = JSON.parse( publishModules[subDir] = JSON.parse(
plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')), plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')),
); );
} }
logger.log('ok', `found ${publishModules.length} publish modules`); logger.log('ok', `found ${publishModules.length} publish modules`);
logger.log('info', `Ordering publish modules...`);
return publishModules; return publishModules;
} }
} }