feat(core): Enhance package publication workflow with dependency handling and CLI improvements.
This commit is contained in:
@ -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.'
|
||||
}
|
||||
|
@ -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`);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ export class TsPublish {
|
||||
packageSubFolder: publishModule,
|
||||
});
|
||||
await publishModuleInstance.init();
|
||||
await publishModuleInstance.createPublishModuleDir();
|
||||
await publishModuleInstance.build();
|
||||
await publishModuleInstance.publish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user