feat(core): Enhance package publication workflow with dependency handling and CLI improvements.

This commit is contained in:
2024-10-21 13:21:47 +02:00
parent ed6e439424
commit a88e417e2f
9 changed files with 260 additions and 16 deletions

View File

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

View File

@ -31,15 +31,21 @@ export class PublishModule {
const jsonData = plugins.smartfile.fs.toObjectSync(
plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json')
);
this.options.dependencies = this.options.dependencies || {};
const monoRepoPackageJson = JSON.parse(
plugins.smartfile.fs.toStringSync(plugins.path.join(this.options.monoRepoDir, 'package.json'))
)
this.options.dependencies = {
...this.options.dependencies,
...jsonData.dependencies,
...(() => {
const resultDependencies = {};
for (const dependency of jsonData.dependencies) {
resultDependencies[dependency] = monoRepoPackageJson.dependencies[dependency];
}
return resultDependencies;
})()
};
this.options.name = this.options.name || jsonData.name;
this.options.version = plugins.smartfile.fs.toObjectSync(
plugins.path.join(this.options.monoRepoDir, 'package.json')
).version;
this.options.version = monoRepoPackageJson.version;
// now that we have a name and version, lets check if there is already a package under the same name and version.
const smartnpmInstance = new plugins.smartnpm.NpmRegistry({}); // TODO: pass in options
@ -102,4 +108,18 @@ export class PublishModule {
// ts folder
await plugins.smartfile.fs.copy(this.options.packageSubFolderFullPath, plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder))
}
public async build() {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
})
await smartshellInstance.exec(`cd ${this.options.publishModDirFullPath} && pnpm run build`);
}
public async publish() {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
})
await smartshellInstance.exec(`cd ${this.options.publishModDirFullPath} && pnpm publish`);
}
}

View File

@ -14,6 +14,9 @@ export class TsPublish {
packageSubFolder: publishModule,
});
await publishModuleInstance.init();
await publishModuleInstance.createPublishModuleDir();
await publishModuleInstance.build();
await publishModuleInstance.publish();
}
}

View File

@ -10,5 +10,6 @@ import * as smartcli from '@push.rocks/smartcli';
import * as smartlog from '@push.rocks/smartlog';
import * as smartnpm from '@push.rocks/smartnpm';
import * as smartpath from '@push.rocks/smartpath';
import * as smartshell from '@push.rocks/smartshell';
export { smartfile, smartcli, smartlog, smartnpm, smartpath, };
export { smartfile, smartcli, smartlog, smartnpm, smartpath, smartshell };