feat(core): Enhance package publication workflow with dependency handling and CLI improvements.
This commit is contained in:
@@ -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`);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user