diff --git a/changelog.md b/changelog.md index 9357133..fef041e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-10-28 - 1.5.0 - feat(classes.publishmodule) +Add method to create and write tsconfig.json during publish module setup + +- Introduced createTsconfigJson method in PublishModule class to generate a tsconfig.json for each publishable module. +- Modified createPublishModuleDir method to include writing of tsconfig.json file. + ## 2024-10-26 - 1.4.0 - feat(core) Refactor directory reading and module discovery for publishing process diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 2abbb47..fc2d048 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.4.0', + version: '1.5.0', 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.publishmodule.ts b/ts/classes.publishmodule.ts index 4008e52..4f5db4c 100644 --- a/ts/classes.publishmodule.ts +++ b/ts/classes.publishmodule.ts @@ -76,6 +76,31 @@ export class PublishModule { return packageInfo.allVersions[0].version; } + public async createTsconfigJson() { + const originalTsConfig = plugins.smartfile.fs.toObjectSync( + plugins.path.join(paths.cwd, 'tsconfig.json') + ); + for (const path of originalTsConfig.compilerOptions.paths) { + originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`; + } + const tsconfigJson = { + compilerOptions: { + experimentalDecorators: true, + useDefineForClassFields: false, + target: 'ES2022', + module: 'NodeNext', + moduleResolution: 'NodeNext', + esModuleInterop: true, + verbatimModuleSyntax: true, + paths: originalTsConfig.compilerOptions.paths, + }, + exclude: [ + 'dist_*/**/*.d.ts', + ], + }; + return JSON.stringify(tsconfigJson, null, 2); + } + public async createPackageJson() { const packageJson = { name: this.options.name, @@ -125,6 +150,14 @@ export class PublishModule { ); await packageJson.write(); + // tsconfig.json + const originalTsConfigJson = await plugins.smartfile.SmartFile.fromString( + plugins.path.join(this.options.publishModDirFullPath, 'tsconfig.json'), + await this.createTsconfigJson(), + 'utf8' + ); + await originalTsConfigJson.write(); + // ts folder await plugins.smartfile.fs.copy( this.options.packageSubFolderFullPath,