fix(readme): clarify usage examples and API documentation
This commit is contained in:
@@ -155,7 +155,7 @@ If `registries` is an empty array `[]`, the package will be built but **not publ
|
||||
|
||||
When packages depend on each other, use the `order` field to control build sequence:
|
||||
|
||||
```json
|
||||
```jsonc
|
||||
// ts_core/tspublish.json — builds first
|
||||
{
|
||||
"name": "@myorg/core",
|
||||
@@ -200,28 +200,14 @@ TSPublish will:
|
||||
import { TsPublish } from '@git.zone/tspublish';
|
||||
|
||||
const publisher = new TsPublish();
|
||||
|
||||
// Publish all discovered modules in the current directory
|
||||
await publisher.publish(process.cwd());
|
||||
```
|
||||
|
||||
#### Custom Publishing Pipeline
|
||||
|
||||
```typescript
|
||||
import { TsPublish, PublishModule } from '@git.zone/tspublish';
|
||||
|
||||
const publisher = new TsPublish();
|
||||
// Or just discover modules without publishing
|
||||
const modules = await publisher.getModuleSubDirs('./my-monorepo');
|
||||
|
||||
for (const [name, config] of Object.entries(modules)) {
|
||||
const mod = new PublishModule(publisher, {
|
||||
monoRepoDir: './my-monorepo',
|
||||
packageSubFolder: name,
|
||||
});
|
||||
|
||||
await mod.init(); // Resolve deps, validate version
|
||||
await mod.createPublishModuleDir(); // Scaffold dist_publish_* directory
|
||||
await mod.build(); // Compile TypeScript
|
||||
await mod.publish(); // Publish to registries
|
||||
}
|
||||
console.log(modules);
|
||||
// => { ts_core: { name: '@myorg/core', order: 1, ... }, ts_utils: { ... } }
|
||||
```
|
||||
|
||||
## 🔧 How It Works
|
||||
@@ -263,6 +249,8 @@ For each discovered module, tspublish:
|
||||
|
||||
### TsPublish
|
||||
|
||||
The main class that orchestrates the entire publishing pipeline.
|
||||
|
||||
```typescript
|
||||
class TsPublish {
|
||||
/** Publish all discovered modules in a monorepo directory */
|
||||
@@ -273,26 +261,10 @@ class TsPublish {
|
||||
}
|
||||
```
|
||||
|
||||
### PublishModule
|
||||
|
||||
```typescript
|
||||
class PublishModule {
|
||||
/** Initialize: resolve dependencies, validate version against registry */
|
||||
async init(): Promise<void>;
|
||||
|
||||
/** Create the dist_publish_* directory with all necessary files */
|
||||
async createPublishModuleDir(): Promise<void>;
|
||||
|
||||
/** Build the TypeScript package */
|
||||
async build(): Promise<void>;
|
||||
|
||||
/** Publish to all configured registries */
|
||||
async publish(): Promise<void>;
|
||||
}
|
||||
```
|
||||
|
||||
### ITsPublishJson
|
||||
|
||||
The configuration interface for each `tspublish.json` file:
|
||||
|
||||
```typescript
|
||||
interface ITsPublishJson {
|
||||
name: string; // Published package name
|
||||
@@ -305,6 +277,8 @@ interface ITsPublishJson {
|
||||
|
||||
### GiteaAssets
|
||||
|
||||
Utility class for fetching files from Gitea repositories (used internally for CLI template retrieval):
|
||||
|
||||
```typescript
|
||||
class GiteaAssets {
|
||||
constructor(options: { giteaBaseUrl: string; token?: string });
|
||||
|
||||
Reference in New Issue
Block a user