feat(core): Add runCli function to execute TsPublish process
This commit is contained in:
parent
c0d81402fb
commit
4f555a2fe9
13
changelog.md
Normal file
13
changelog.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-10-21 - 1.1.0 - feat(core)
|
||||||
|
Add runCli function to execute TsPublish process
|
||||||
|
|
||||||
|
- Introduced runCli function to start publish workflow using TsPublish class.
|
||||||
|
- Enhanced the process to read directory and create publish module directories.
|
||||||
|
- Improved logging for better tracking of found publish modules.
|
||||||
|
|
||||||
|
## 2024-10-21 - 1.0.1 - Initial Release
|
||||||
|
Initial release of the project.
|
||||||
|
|
||||||
|
- First version of the codebase
|
@ -2,7 +2,7 @@
|
|||||||
* autocreated commitinfo by @push.rocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@idp.global/idp.global',
|
name: '@git.zone/tspublish',
|
||||||
version: '1.4.2',
|
version: '1.1.0',
|
||||||
description: 'An identity provider software managing user authentications, registrations, and sessions.'
|
description: 'publish multiple, concise and small packages from monorepos'
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export interface IPublishModuleOptions {
|
|||||||
publishModDirFullPath?: string;
|
publishModDirFullPath?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
dependencies?: {[key: string]: string};
|
dependencies?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PublishModule {
|
export class PublishModule {
|
||||||
@ -19,7 +19,6 @@ export class PublishModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async init() {
|
public async init() {
|
||||||
|
|
||||||
this.options.packageSubFolderFullPath = plugins.path.join(
|
this.options.packageSubFolderFullPath = plugins.path.join(
|
||||||
this.options.monoRepoDir,
|
this.options.monoRepoDir,
|
||||||
this.options.packageSubFolder
|
this.options.packageSubFolder
|
||||||
@ -30,7 +29,7 @@ export class PublishModule {
|
|||||||
throw new Error('subFolder must start with "ts"');
|
throw new Error('subFolder must start with "ts"');
|
||||||
}
|
}
|
||||||
const jsonData = plugins.smartfile.fs.toObjectSync(
|
const jsonData = plugins.smartfile.fs.toObjectSync(
|
||||||
plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json'),
|
plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json')
|
||||||
);
|
);
|
||||||
this.options.dependencies = this.options.dependencies || {};
|
this.options.dependencies = this.options.dependencies || {};
|
||||||
this.options.dependencies = {
|
this.options.dependencies = {
|
||||||
@ -46,13 +45,14 @@ export class PublishModule {
|
|||||||
const smartnpmInstance = new plugins.smartnpm.NpmRegistry({}); // TODO: pass in options
|
const smartnpmInstance = new plugins.smartnpm.NpmRegistry({}); // TODO: pass in options
|
||||||
const packageInfo = await smartnpmInstance.getPackageInfo(this.options.name);
|
const packageInfo = await smartnpmInstance.getPackageInfo(this.options.name);
|
||||||
if (packageInfo) {
|
if (packageInfo) {
|
||||||
const availableVersions = packageInfo.allVersions.map(versionArg => versionArg.version);
|
const availableVersions = packageInfo.allVersions.map((versionArg) => versionArg.version);
|
||||||
logger.log('info', `available versions are: ${availableVersions.toString()}`);
|
logger.log('info', `available versions are: ${availableVersions.toString()}`);
|
||||||
if (availableVersions.includes(this.options.version)) {
|
if (availableVersions.includes(this.options.version)) {
|
||||||
throw new Error(`package ${this.options.name} already exists with version ${this.options.version}`);
|
throw new Error(
|
||||||
};
|
`package ${this.options.name} already exists with version ${this.options.version}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getLatestVersionOfPackage(name: string) {
|
public async getLatestVersionOfPackage(name: string) {
|
||||||
@ -69,9 +69,9 @@ export class PublishModule {
|
|||||||
name: this.options.name,
|
name: this.options.name,
|
||||||
version: this.options.version,
|
version: this.options.version,
|
||||||
description: '',
|
description: '',
|
||||||
exports : {
|
exports: {
|
||||||
'.': {
|
'.': {
|
||||||
import: './dist/index.js',
|
import: './dist_${this.options.packageSubFolder}/index.js',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
scripts: {
|
scripts: {
|
||||||
@ -81,7 +81,8 @@ export class PublishModule {
|
|||||||
devDependencies: {
|
devDependencies: {
|
||||||
'@git.zone/tsbuild': await this.getLatestVersionOfPackage('@git.zone/tsbuild'),
|
'@git.zone/tsbuild': await this.getLatestVersionOfPackage('@git.zone/tsbuild'),
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
return JSON.stringify(packageJson, null, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createPublishModuleDir() {
|
public async createPublishModuleDir() {
|
||||||
@ -89,7 +90,16 @@ export class PublishModule {
|
|||||||
this.options.monoRepoDir,
|
this.options.monoRepoDir,
|
||||||
`dist_publish_${this.options.packageSubFolder}`
|
`dist_publish_${this.options.packageSubFolder}`
|
||||||
);
|
);
|
||||||
await plugins.smartfile.fs.ensureEmptyDir(publishModDir);
|
|
||||||
plugins.
|
// package.json
|
||||||
|
await plugins.smartfile.fs.ensureEmptyDir(this.options.publishModDirFullPath);
|
||||||
|
const packageJson = await plugins.smartfile.SmartFile.fromString(
|
||||||
|
plugins.path.join(this.options.publishModDirFullPath, 'package.json'),
|
||||||
|
await this.createPackageJson(),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
|
// ts folder
|
||||||
|
await plugins.smartfile.fs.copy(this.options.packageSubFolderFullPath, plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1,9 @@
|
|||||||
|
import * as paths from './paths.js';
|
||||||
|
import { TsPublish } from './classes.tspublish.js';
|
||||||
|
|
||||||
export * from './classes.tspublish.js'
|
export * from './classes.tspublish.js'
|
||||||
|
|
||||||
|
export const runCli = async () => {
|
||||||
|
const tspublish = new TsPublish();
|
||||||
|
await tspublish.publish(paths.cwd);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user