2 Commits

Author SHA1 Message Date
9814f3ade2 v1.11.0
Some checks failed
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-12-16 12:29:39 +00:00
0f1fa22c46 feat(publish): add registry resolution (useBase/extendBase) and migrate filesystem operations to async SmartFs; improve publish flow and docs 2025-12-16 12:29:39 +00:00
10 changed files with 2793 additions and 2281 deletions

View File

@@ -1,5 +1,15 @@
# Changelog
## 2025-12-16 - 1.11.0 - feat(publish)
add registry resolution (useBase/extendBase) and migrate filesystem operations to async SmartFs; improve publish flow and docs
- Add resolveRegistries supporting 'useBase' and 'extendBase' and explicit registries; reads base registries from npmextra.json at @git.zone/cli.release
- Migrate sync smartfile APIs to async @push.rocks/smartfs and expose smartfs and npmextra via plugins
- Ensure publish directory is recreated cleanly and use async file copy/read/write for package, tsconfig, readme and license
- Handle empty registries by skipping publish with a warning and throw a clear error if useBase/extendBase is used but no base registries configured
- Publish now normalizes registry URLs and supports accessLevel per-registry when running pnpm publish
- Update README: registry configuration docs, issue reporting/security section and various wording/formatting improvements; bump several dependencies/devDependencies
## 2025-12-15 - 1.10.4 - fix(.serena)
cleanup: remove .serena assistant memories, cache and project config

View File

@@ -1,5 +1,5 @@
{
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
@@ -21,10 +21,16 @@
"module-management",
"developer-tools"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"@ship.zone/szci": {
"npmGlobalTools": []
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@git.zone/tspublish",
"version": "1.10.4",
"version": "1.11.0",
"private": false,
"description": "A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.",
"main": "dist_ts/index.js",
@@ -17,11 +17,11 @@
"tspublish": "./cli.js"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.6.6",
"@git.zone/tsbundle": "^2.5.1",
"@git.zone/tsrun": "^1.3.3",
"@git.zone/tstest": "^2.3.4",
"@types/node": "^22.8.7"
"@git.zone/tsbuild": "^4.0.2",
"@git.zone/tsbundle": "^2.6.3",
"@git.zone/tsrun": "^2.0.1",
"@git.zone/tstest": "^3.1.3",
"@types/node": "^25.0.2"
},
"repository": {
"type": "git",
@@ -48,13 +48,15 @@
],
"dependencies": {
"@push.rocks/consolecolor": "^2.0.3",
"@push.rocks/smartcli": "^4.0.11",
"@push.rocks/npmextra": "^5.3.3",
"@push.rocks/smartcli": "^4.0.19",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.2.7",
"@push.rocks/smartlog": "^3.1.8",
"@push.rocks/smartfile": "^13.1.2",
"@push.rocks/smartfs": "^1.3.1",
"@push.rocks/smartlog": "^3.1.10",
"@push.rocks/smartnpm": "^2.0.6",
"@push.rocks/smartpath": "^6.0.0",
"@push.rocks/smartrequest": "^4.2.2",
"@push.rocks/smartrequest": "^5.0.1",
"@push.rocks/smartshell": "^3.3.0"
},
"keywords": [

4753
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +0,0 @@
onlyBuiltDependencies:
- esbuild
- mongodb-memory-server
- puppeteer

View File

@@ -9,6 +9,10 @@
`@git.zone/tspublish` is your Swiss Army knife for managing and publishing multiple TypeScript packages from a monorepo. It automates the tedious parts of package publishing while giving you full control over the process. Whether you're maintaining a suite of microservices, a component library, or any collection of related packages, tspublish makes your life easier.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
### ✨ Key Features
- 📦 **Automatic Package Discovery** - Scans your monorepo for publishable packages
@@ -149,7 +153,11 @@ for (const [name, config] of Object.entries(modules)) {
### Registry Configuration
TSPublish supports multiple registries with different access levels:
TSPublish supports multiple registries with different access levels. You have three approaches:
#### 1⃣ Explicit Registries
Define specific registries directly in your `tspublish.json`:
```json
{
@@ -161,6 +169,38 @@ TSPublish supports multiple registries with different access levels:
}
```
#### 2⃣ Use Base Configuration (`useBase`)
Inherit registries from your project's `npmextra.json` configuration (managed by `gitzone config`):
```json
{
"registries": ["useBase"]
}
```
This reads from `npmextra.json` under `@git.zone/cli.release.registries`.
#### 3⃣ Extend Base Configuration (`extendBase`)
Start with base registries and add/remove specific ones:
```json
{
"registries": [
"extendBase",
"custom-registry.example.com:public",
"-https://registry.npmjs.org" // Exclude this registry
]
}
```
The `-` prefix excludes a registry from the base configuration.
#### Empty Registries
If no registries are configured, the package will be built but **not published** (a warning is logged).
### Build Order Management
When packages depend on each other, use the `order` field to ensure correct build sequence:
@@ -346,30 +386,27 @@ interface ITsPublishJson {
- Check that all dependencies are installed
- Review the build output for specific errors
## 🔮 Future Features
- 🎯 Selective publishing with pattern matching
- 🔄 Automatic version bumping strategies
- 📊 Dry-run mode with detailed preview
- 🏷️ Git tag integration
- 📝 Changelog generation
- 🔐 Enhanced authentication handling
**useBase/extendBase error**
- Ensure your `npmextra.json` has registries configured at `@git.zone/cli.release.registries`
- Use `gitzone config add <registry-url>` to configure base registries
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

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

View File

@@ -16,6 +16,11 @@ export interface IPublishModuleOptions {
dependencies?: { [key: string]: string };
}
export interface IResolvedRegistry {
url: string;
accessLevel: string;
}
export class PublishModule {
tsPublishRef: TsPublish;
public options: IPublishModuleOptions;
@@ -34,14 +39,14 @@ export class PublishModule {
if (!this.options.packageSubFolder.startsWith('ts')) {
throw new Error('subFolder must start with "ts"');
}
this.options.tsPublishJson = plugins.smartfile.fs.toObjectSync(
plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json')
);
const tspublishJsonPath = plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json');
const tspublishJsonContent = await plugins.smartfs.file(tspublishJsonPath).encoding('utf8').read();
this.options.tsPublishJson = JSON.parse(tspublishJsonContent as string);
// the package.json of the parent mono repo
const monoRepoPackageJson = JSON.parse(
plugins.smartfile.fs.toStringSync(plugins.path.join(this.options.monoRepoDir, 'package.json'))
);
const packageJsonPath = plugins.path.join(this.options.monoRepoDir, 'package.json');
const packageJsonContent = await plugins.smartfs.file(packageJsonPath).encoding('utf8').read();
const monoRepoPackageJson = JSON.parse(packageJsonContent as string);
this.options.dependencies = {
...this.options.dependencies,
@@ -91,9 +96,12 @@ export class PublishModule {
}
public async createTsconfigJson() {
const originalTsConfig = plugins.smartfile.fs.toObjectSync(
plugins.path.join(paths.cwd, 'tsconfig.json')
);
const tsconfigPath = plugins.path.join(paths.cwd, 'tsconfig.json');
let originalTsConfig: any = null;
if (await plugins.smartfs.file(tsconfigPath).exists()) {
const tsconfigContent = await plugins.smartfs.file(tsconfigPath).encoding('utf8').read();
originalTsConfig = JSON.parse(tsconfigContent as string);
}
if (originalTsConfig?.compilerOptions?.paths) {
for (const path of Object.keys(originalTsConfig.compilerOptions.paths)) {
originalTsConfig.compilerOptions.paths[
@@ -166,41 +174,35 @@ export class PublishModule {
this.options.monoRepoDir,
`dist_publish_${this.options.packageSubFolder}`
);
await plugins.smartfile.fs.ensureEmptyDir(this.options.publishModDirFullPath);
// Ensure empty directory
const publishDir = plugins.smartfs.directory(this.options.publishModDirFullPath);
if (await publishDir.exists()) {
await publishDir.recursive().delete();
}
await publishDir.recursive().create();
// package.json
const packageJson = await plugins.smartfile.SmartFile.fromString(
plugins.path.join(this.options.publishModDirFullPath, 'package.json'),
await this.createPackageJson(),
'utf8'
);
await packageJson.write();
const packageJsonPath = plugins.path.join(this.options.publishModDirFullPath, 'package.json');
await plugins.smartfs.file(packageJsonPath).encoding('utf8').write(await this.createPackageJson());
// tsconfig.json
const tsconfigJson = await plugins.smartfile.SmartFile.fromString(
plugins.path.join(this.options.publishModDirFullPath, 'tsconfig.json'),
await this.createTsconfigJson(),
'utf8'
);
await tsconfigJson.write();
const tsconfigJsonPath = plugins.path.join(this.options.publishModDirFullPath, 'tsconfig.json');
await plugins.smartfs.file(tsconfigJsonPath).encoding('utf8').write(await this.createTsconfigJson());
// ts subfolder, the folder that contains the source code and is being transpiled
await plugins.smartfile.fs.copy(
this.options.packageSubFolderFullPath,
plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder)
);
const destSubFolder = plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder);
await plugins.smartfs.directory(this.options.packageSubFolderFullPath).recursive().copy(destSubFolder);
// readme
await plugins.smartfile.fs.copy(
plugins.path.join(this.options.packageSubFolderFullPath, 'readme.md'),
plugins.path.join(this.options.publishModDirFullPath, 'readme.md')
);
const readmeSrc = plugins.path.join(this.options.packageSubFolderFullPath, 'readme.md');
const readmeDest = plugins.path.join(this.options.publishModDirFullPath, 'readme.md');
await plugins.smartfs.file(readmeSrc).copy(readmeDest);
// license
await plugins.smartfile.fs.copy(
plugins.path.join(this.options.monoRepoDir, 'license'),
plugins.path.join(this.options.publishModDirFullPath, 'license')
);
const licenseSrc = plugins.path.join(this.options.monoRepoDir, 'license');
const licenseDest = plugins.path.join(this.options.publishModDirFullPath, 'license');
await plugins.smartfs.file(licenseSrc).copy(licenseDest);
// cli stuff
this.createBinCliSetup();
@@ -227,22 +229,104 @@ export class PublishModule {
);
const indexPath = `./dist_${this.options.packageSubFolder}/index.js`;
const fileContent = atob(files[0].base64Content).replace('./dist_ts/index.js', indexPath);
await plugins.smartfile.memory.toFs(fileContent, plugins.path.join(this.options.publishModDirFullPath, 'cli.js'));
const cliJsPath = plugins.path.join(this.options.publishModDirFullPath, 'cli.js');
await plugins.smartfs.file(cliJsPath).encoding('utf8').write(fileContent);
}
/**
* Resolves the registries to publish to based on tspublish.json configuration.
* Supports:
* - "useBase": Use only registries from npmextra.json
* - "extendBase": Use base registries + additions, with exclusions via "-" prefix
* - Explicit registries: Direct registry URLs in format "url:accessLevel"
*/
private async resolveRegistries(): Promise<IResolvedRegistry[]> {
const rawRegistries = this.options.tsPublishJson?.registries || [];
// Empty → skip publishing
if (rawRegistries.length === 0) {
return [];
}
const hasUseBase = rawRegistries.includes('useBase');
const hasExtendBase = rawRegistries.includes('extendBase');
let baseRegistries: string[] = [];
let baseAccessLevel = 'public';
// Load base registries from npmextra.json if needed
if (hasUseBase || hasExtendBase) {
const npmextraInstance = new plugins.npmextra.Npmextra(this.options.monoRepoDir);
const gitzoneConfig = npmextraInstance.dataFor<any>('@git.zone/cli', {});
baseRegistries = gitzoneConfig?.release?.registries || [];
baseAccessLevel = gitzoneConfig?.release?.accessLevel || 'public';
if (baseRegistries.length === 0) {
throw new Error(
`useBase/extendBase specified in tspublish.json but no registries configured in npmextra.json at @git.zone/cli.release.registries`
);
}
}
// useBase: Only base registries
if (hasUseBase) {
return baseRegistries.map((url) => ({ url, accessLevel: baseAccessLevel }));
}
// extendBase: Base registries + additions - exclusions
if (hasExtendBase) {
const exclusions = rawRegistries
.filter((r) => r.startsWith('-'))
.map((r) => r.slice(1)); // remove '-' prefix
const additions = rawRegistries.filter((r) => r !== 'extendBase' && !r.startsWith('-'));
// Filter out excluded base registries
const result: IResolvedRegistry[] = baseRegistries
.filter((url) => !exclusions.includes(url))
.map((url) => ({ url, accessLevel: baseAccessLevel }));
// Add explicit registries
for (const addition of additions) {
const parts = addition.split(':');
const url = parts[0];
const access = parts[1] || 'public';
result.push({ url, accessLevel: access });
}
return result;
}
// Explicit registries only (original behavior)
return rawRegistries.map((r) => {
const parts = r.split(':');
const url = parts[0];
const access = parts[1] || 'public';
return { url, accessLevel: access };
});
}
public async publish() {
logPublish(`Publishing ${this.options.name} v${this.options.version}...`);
const registries = await this.resolveRegistries();
// Handle empty registries
if (registries.length === 0) {
logWarn(`No registries configured for ${this.options.name}. Skipping publish.`);
return;
}
logPublish(`Publishing ${this.options.name} v${this.options.version} to ${registries.length} registry(ies)...`);
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
});
for (const registry of this.options.tsPublishJson.registries) {
const registryArray = registry.split(':');
const registryUrl = registryArray[0];
const registryAccessLevel = registryArray[1];
for (const registry of registries) {
const registryUrl = registry.url.startsWith('https://') ? registry.url : `https://${registry.url}`;
logOngoing(`Publishing to ${registryUrl}...`);
await smartshellInstance.exec(
`cd ${this.options.publishModDirFullPath} && pnpm publish ${
registryAccessLevel === 'public' ? '--access public' : ''
} --no-git-checks --registry https://${registryUrl}`
registry.accessLevel === 'public' ? '--access public' : ''
} --no-git-checks --registry ${registryUrl}`
);
}
logSuccess(`Successfully published ${this.options.name} v${this.options.version}!`);

View File

@@ -43,22 +43,27 @@ export class TsPublish {
}
public async getModuleSubDirs(dirArg: string) {
const subDirs = await plugins.smartfile.fs.listFolders(dirArg);
// List all directories
const dirContents = await plugins.smartfs.directory(dirArg).list();
const publishModules: { [key: string]: interfaces.ITsPublishJson } = {};
for (const subDir of subDirs) {
if (!subDir.startsWith('ts')) {
continue;
}
const fileTree = await plugins.smartfile.fs.listFileTree(subDir, '**/*');
const hasPublishJson = fileTree.includes('tspublish.json');
if (!hasPublishJson) {
for (const entry of dirContents) {
const subDirName = entry.name;
if (!subDirName.startsWith('ts')) {
continue;
}
logPackage('Found module', subDir);
publishModules[subDir] = JSON.parse(
plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json'))
);
// Check if this is a directory and has tspublish.json
const subDirPath = plugins.path.join(dirArg, subDirName);
const tspublishJsonPath = plugins.path.join(subDirPath, 'tspublish.json');
if (!(await plugins.smartfs.file(tspublishJsonPath).exists())) {
continue;
}
logPackage('Found module', subDirName);
const tspublishContent = await plugins.smartfs.file(tspublishJsonPath).encoding('utf8').read();
publishModules[subDirName] = JSON.parse(tspublishContent as string);
}
logSuccess(`Found ${Object.keys(publishModules).length} publish modules`);
logInfo('Ordering publish modules...');

View File

@@ -4,7 +4,9 @@ export { path };
// @push.rocks scope
import * as consolecolor from '@push.rocks/consolecolor';
import * as npmextra from '@push.rocks/npmextra';
import * as smartfile from '@push.rocks/smartfile';
import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
import * as smartcli from '@push.rocks/smartcli';
import * as smartdelay from '@push.rocks/smartdelay';
import * as smartlog from '@push.rocks/smartlog';
@@ -13,4 +15,7 @@ import * as smartpath from '@push.rocks/smartpath';
import * as smartrequest from '@push.rocks/smartrequest';
import * as smartshell from '@push.rocks/smartshell';
export { consolecolor, smartfile, smartcli, smartdelay, smartlog, smartnpm, smartpath, smartrequest, smartshell };
// Create a pre-configured SmartFs instance for Node.js filesystem operations
const smartfs = new SmartFs(new SmartFsProviderNode());
export { consolecolor, npmextra, smartfile, smartfs, smartcli, smartdelay, smartlog, smartnpm, smartpath, smartrequest, smartshell };