Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
5b768288c5 | |||
023aea2494 | |||
ac839d5419 | |||
750f081c03 | |||
125be257d6 | |||
d4c7fa8d6b | |||
9d41d036f5 | |||
94c38e21b3 |
26
changelog.md
26
changelog.md
@ -1,5 +1,31 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-11-05 - 1.7.3 - fix(TsPublish)
|
||||||
|
Add validation for tspublish.json name field
|
||||||
|
|
||||||
|
- Ensure that the tspublish.json file contains a valid name field before processing.
|
||||||
|
- Log a warning message if the name is not found in tspublish.json.
|
||||||
|
|
||||||
|
## 2024-11-05 - 1.7.2 - fix(project)
|
||||||
|
Fixed minor formatting issues and improved code consistency.
|
||||||
|
|
||||||
|
- Added missing semicolons for consistency
|
||||||
|
- Improved indentation in various files for better readability
|
||||||
|
- Corrected usage of newlines and whitespace across the codebase
|
||||||
|
|
||||||
|
## 2024-11-05 - 1.7.1 - fix(core)
|
||||||
|
Implement error handling for missing publish module directories
|
||||||
|
|
||||||
|
- Improved logging for package publish steps
|
||||||
|
- Enhanced CLI feedback messages during the publishing process
|
||||||
|
- Restructured package.json to ensure proper dependencies are published
|
||||||
|
|
||||||
|
## 2024-11-05 - 1.7.0 - feat(core)
|
||||||
|
Enhanced tspublish with ordered compilation and updated dependencies
|
||||||
|
|
||||||
|
- Added 'order' property to ITsPublishJson interface to ensure project compilation order.
|
||||||
|
- Updated development dependencies: @git.zone/tsbuild, @git.zone/tsbundle, @git.zone/tsrun, and @types/node.
|
||||||
|
|
||||||
## 2024-10-28 - 1.6.0 - feat(classes.publishmodule)
|
## 2024-10-28 - 1.6.0 - feat(classes.publishmodule)
|
||||||
Added copying of readme and license files to publish directory
|
Added copying of readme and license files to publish directory
|
||||||
|
|
||||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tspublish",
|
"name": "@git.zone/tspublish",
|
||||||
"version": "1.6.0",
|
"version": "1.7.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.",
|
"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",
|
"main": "dist_ts/index.js",
|
||||||
@ -17,12 +17,12 @@
|
|||||||
"tspublish": "cli.js"
|
"tspublish": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.25",
|
"@git.zone/tsbuild": "^2.1.85",
|
||||||
"@git.zone/tsbundle": "^2.0.5",
|
"@git.zone/tsbundle": "^2.1.0",
|
||||||
"@git.zone/tsrun": "^1.2.46",
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
"@git.zone/tstest": "^1.0.44",
|
"@git.zone/tstest": "^1.0.44",
|
||||||
"@push.rocks/tapbundle": "^5.0.15",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^22.7.7"
|
"@types/node": "^22.8.7"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
692
pnpm-lock.yaml
generated
692
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
14
readme.md
14
readme.md
@ -172,11 +172,13 @@ Follow these steps:
|
|||||||
```typescript
|
```typescript
|
||||||
import { runCli } from '@git.zone/tspublish';
|
import { runCli } from '@git.zone/tspublish';
|
||||||
|
|
||||||
runCli().then(() => {
|
runCli()
|
||||||
console.log('Publishing completed successfully');
|
.then(() => {
|
||||||
}).catch((error) => {
|
console.log('Publishing completed successfully');
|
||||||
console.error('Error during publishing:', error);
|
})
|
||||||
});
|
.catch((error) => {
|
||||||
|
console.error('Error during publishing:', error);
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Execute your CLI script:
|
3. Execute your CLI script:
|
||||||
@ -188,4 +190,4 @@ node publish.js
|
|||||||
Your script will call `runCli`, which will traverse each `ts-package`, verify their publish readiness, and handle individual publishing processes.
|
Your script will call `runCli`, which will traverse each `ts-package`, verify their publish readiness, and handle individual publishing processes.
|
||||||
|
|
||||||
By following these comprehensive guidelines and utilizing the structured approach provided by `@git.zone/tspublish`, you can efficiently manage and publish multiple sub-packages from within a monorepo, facilitating organized, modular package management in projects of any scale.
|
By following these comprehensive guidelines and utilizing the structured approach provided by `@git.zone/tspublish`, you can efficiently manage and publish multiple sub-packages from within a monorepo, facilitating organized, modular package management in projects of any scale.
|
||||||
undefined
|
undefined
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tspublish',
|
name: '@git.zone/tspublish',
|
||||||
version: '1.6.0',
|
version: '1.7.3',
|
||||||
description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.'
|
description: 'A tool to publish multiple, concise, and small packages from monorepos, specifically for TypeScript projects within a git environment.'
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ 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,
|
||||||
);
|
);
|
||||||
|
|
||||||
// check requirements
|
// check requirements
|
||||||
@ -36,10 +36,12 @@ export class PublishModule {
|
|||||||
throw new Error('subFolder must start with "ts"');
|
throw new Error('subFolder must start with "ts"');
|
||||||
}
|
}
|
||||||
this.options.tsPublishJson = plugins.smartfile.fs.toObjectSync(
|
this.options.tsPublishJson = plugins.smartfile.fs.toObjectSync(
|
||||||
plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json')
|
plugins.path.join(this.options.packageSubFolderFullPath, 'tspublish.json'),
|
||||||
);
|
);
|
||||||
const monoRepoPackageJson = JSON.parse(
|
const monoRepoPackageJson = JSON.parse(
|
||||||
plugins.smartfile.fs.toStringSync(plugins.path.join(this.options.monoRepoDir, 'package.json'))
|
plugins.smartfile.fs.toStringSync(
|
||||||
|
plugins.path.join(this.options.monoRepoDir, 'package.json'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
this.options.dependencies = {
|
this.options.dependencies = {
|
||||||
...this.options.dependencies,
|
...this.options.dependencies,
|
||||||
@ -67,7 +69,10 @@ export class PublishModule {
|
|||||||
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)) {
|
||||||
logger.log('error', `package ${this.options.name} already exists with version ${this.options.version}`);
|
logger.log(
|
||||||
|
'error',
|
||||||
|
`package ${this.options.name} already exists with version ${this.options.version}`,
|
||||||
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,11 +89,12 @@ export class PublishModule {
|
|||||||
|
|
||||||
public async createTsconfigJson() {
|
public async createTsconfigJson() {
|
||||||
const originalTsConfig = plugins.smartfile.fs.toObjectSync(
|
const originalTsConfig = plugins.smartfile.fs.toObjectSync(
|
||||||
plugins.path.join(paths.cwd, 'tsconfig.json')
|
plugins.path.join(paths.cwd, 'tsconfig.json'),
|
||||||
);
|
);
|
||||||
if (originalTsConfig?.compilerOptions?.paths) {
|
if (originalTsConfig?.compilerOptions?.paths) {
|
||||||
for (const path of Object.keys(originalTsConfig.compilerOptions.paths)) {
|
for (const path of Object.keys(originalTsConfig.compilerOptions.paths)) {
|
||||||
originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`;
|
originalTsConfig.compilerOptions.paths[path][0] =
|
||||||
|
`.${originalTsConfig.compilerOptions.paths[path][0]}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tsconfigJson = {
|
const tsconfigJson = {
|
||||||
@ -102,9 +108,7 @@ export class PublishModule {
|
|||||||
verbatimModuleSyntax: true,
|
verbatimModuleSyntax: true,
|
||||||
paths: originalTsConfig?.compilerOptions?.paths,
|
paths: originalTsConfig?.compilerOptions?.paths,
|
||||||
},
|
},
|
||||||
exclude: [
|
exclude: ['dist_*/**/*.d.ts'],
|
||||||
'dist_*/**/*.d.ts',
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
return JSON.stringify(tsconfigJson, null, 2);
|
return JSON.stringify(tsconfigJson, null, 2);
|
||||||
}
|
}
|
||||||
@ -146,7 +150,7 @@ export class PublishModule {
|
|||||||
public async createPublishModuleDir() {
|
public async createPublishModuleDir() {
|
||||||
this.options.publishModDirFullPath = plugins.path.join(
|
this.options.publishModDirFullPath = plugins.path.join(
|
||||||
this.options.monoRepoDir,
|
this.options.monoRepoDir,
|
||||||
`dist_publish_${this.options.packageSubFolder}`
|
`dist_publish_${this.options.packageSubFolder}`,
|
||||||
);
|
);
|
||||||
await plugins.smartfile.fs.ensureEmptyDir(this.options.publishModDirFullPath);
|
await plugins.smartfile.fs.ensureEmptyDir(this.options.publishModDirFullPath);
|
||||||
|
|
||||||
@ -154,7 +158,7 @@ export class PublishModule {
|
|||||||
const packageJson = await plugins.smartfile.SmartFile.fromString(
|
const packageJson = await plugins.smartfile.SmartFile.fromString(
|
||||||
plugins.path.join(this.options.publishModDirFullPath, 'package.json'),
|
plugins.path.join(this.options.publishModDirFullPath, 'package.json'),
|
||||||
await this.createPackageJson(),
|
await this.createPackageJson(),
|
||||||
'utf8'
|
'utf8',
|
||||||
);
|
);
|
||||||
await packageJson.write();
|
await packageJson.write();
|
||||||
|
|
||||||
@ -162,26 +166,26 @@ export class PublishModule {
|
|||||||
const originalTsConfigJson = await plugins.smartfile.SmartFile.fromString(
|
const originalTsConfigJson = await plugins.smartfile.SmartFile.fromString(
|
||||||
plugins.path.join(this.options.publishModDirFullPath, 'tsconfig.json'),
|
plugins.path.join(this.options.publishModDirFullPath, 'tsconfig.json'),
|
||||||
await this.createTsconfigJson(),
|
await this.createTsconfigJson(),
|
||||||
'utf8'
|
'utf8',
|
||||||
);
|
);
|
||||||
await originalTsConfigJson.write();
|
await originalTsConfigJson.write();
|
||||||
|
|
||||||
// ts folder
|
// ts folder
|
||||||
await plugins.smartfile.fs.copy(
|
await plugins.smartfile.fs.copy(
|
||||||
this.options.packageSubFolderFullPath,
|
this.options.packageSubFolderFullPath,
|
||||||
plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder)
|
plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder),
|
||||||
);
|
);
|
||||||
|
|
||||||
// readme
|
// readme
|
||||||
await plugins.smartfile.fs.copy(
|
await plugins.smartfile.fs.copy(
|
||||||
plugins.path.join(this.options.packageSubFolderFullPath, 'readme.md'),
|
plugins.path.join(this.options.packageSubFolderFullPath, 'readme.md'),
|
||||||
plugins.path.join(this.options.publishModDirFullPath, 'readme.md')
|
plugins.path.join(this.options.publishModDirFullPath, 'readme.md'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// license
|
// license
|
||||||
await plugins.smartfile.fs.copy(
|
await plugins.smartfile.fs.copy(
|
||||||
plugins.path.join(this.options.monoRepoDir, 'license'),
|
plugins.path.join(this.options.monoRepoDir, 'license'),
|
||||||
plugins.path.join(this.options.publishModDirFullPath, 'license')
|
plugins.path.join(this.options.publishModDirFullPath, 'license'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +207,7 @@ export class PublishModule {
|
|||||||
await smartshellInstance.exec(
|
await smartshellInstance.exec(
|
||||||
`cd ${this.options.publishModDirFullPath} && pnpm publish ${
|
`cd ${this.options.publishModDirFullPath} && pnpm publish ${
|
||||||
registryAccessLevel === 'public' ? '--access public' : ''
|
registryAccessLevel === 'public' ? '--access public' : ''
|
||||||
} --no-git-checks --registry https://${registryUrl}`
|
} --no-git-checks --registry https://${registryUrl}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,14 @@ import { PublishModule } from './classes.publishmodule.js';
|
|||||||
export class TsPublish {
|
export class TsPublish {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
public async publish (monorepoDirArg: string) {
|
public async publish(monorepoDirArg: string) {
|
||||||
const publishModules = await this.getModuleSubDirs(monorepoDirArg);
|
const publishModules = await this.getModuleSubDirs(monorepoDirArg);
|
||||||
logger.log('info', `Found ${Object.keys(publishModules).length} publish modules:`);
|
logger.log('info', `Found ${Object.keys(publishModules).length} publish modules:`);
|
||||||
for (const publishModule of Object.keys(publishModules)) {
|
for (const publishModule of Object.keys(publishModules)) {
|
||||||
logger.log('info', `Publishing module: ${publishModule} -> ${publishModules[publishModule].name}`);
|
logger.log(
|
||||||
|
'info',
|
||||||
|
`Publishing module: ${publishModule} -> ${publishModules[publishModule].name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
for (const publishModule of Object.keys(publishModules)) {
|
for (const publishModule of Object.keys(publishModules)) {
|
||||||
const publishModuleInstance = new PublishModule({
|
const publishModuleInstance = new PublishModule({
|
||||||
@ -25,9 +28,9 @@ export class TsPublish {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getModuleSubDirs (dirArg: string) {
|
public async getModuleSubDirs(dirArg: string) {
|
||||||
const subDirs = await plugins.smartfile.fs.listFolders(dirArg);
|
const subDirs = await plugins.smartfile.fs.listFolders(dirArg);
|
||||||
const publishModules: {[key: string]: interfaces.ITsPublishJson} = {};
|
const publishModules: { [key: string]: interfaces.ITsPublishJson } = {};
|
||||||
for (const subDir of subDirs) {
|
for (const subDir of subDirs) {
|
||||||
if (!subDir.startsWith('ts')) {
|
if (!subDir.startsWith('ts')) {
|
||||||
continue;
|
continue;
|
||||||
@ -37,10 +40,22 @@ export class TsPublish {
|
|||||||
if (!hasPublishJson) {
|
if (!hasPublishJson) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lets check wether there is a name
|
||||||
|
const tspublishJson = JSON.parse(
|
||||||
|
plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')),
|
||||||
|
);
|
||||||
|
if (!tspublishJson.name) {
|
||||||
|
logger.log('warn', `no name found in tspublish.json for ${subDir}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
logger.log('info', `found publish module: ${subDir}`);
|
logger.log('info', `found publish module: ${subDir}`);
|
||||||
publishModules[subDir] = JSON.parse(plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')));
|
publishModules[subDir] = JSON.parse(
|
||||||
|
plugins.smartfile.fs.toStringSync(plugins.path.join(subDir, 'tspublish.json')),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
logger.log('ok', `found ${publishModules.length} publish modules`);
|
logger.log('ok', `found ${publishModules.length} publish modules`);
|
||||||
return publishModules;
|
return publishModules;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import * as paths from './paths.js';
|
import * as paths from './paths.js';
|
||||||
import { TsPublish } from './classes.tspublish.js';
|
import { TsPublish } from './classes.tspublish.js';
|
||||||
|
|
||||||
export * from './classes.tspublish.js'
|
export * from './classes.tspublish.js';
|
||||||
|
|
||||||
export const runCli = async () => {
|
export const runCli = async () => {
|
||||||
console.log('Starting tspublish...');
|
console.log('Starting tspublish...');
|
||||||
const tspublish = new TsPublish();
|
const tspublish = new TsPublish();
|
||||||
await tspublish.publish(paths.cwd);
|
await tspublish.publish(paths.cwd);
|
||||||
}
|
};
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
export interface ITsPublishJson {
|
export interface ITsPublishJson {
|
||||||
|
/**
|
||||||
|
* the order assures that a project is compiled before another project
|
||||||
|
*/
|
||||||
|
order: number;
|
||||||
name: string;
|
name: string;
|
||||||
dependencies: string[];
|
dependencies: string[];
|
||||||
registries: string[];
|
registries: string[];
|
||||||
|
@ -2,4 +2,4 @@ import * as plugins from './plugins.js';
|
|||||||
import * as commitinfo from './00_commitinfo_data.js';
|
import * as commitinfo from './00_commitinfo_data.js';
|
||||||
|
|
||||||
export const logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo.commitinfo);
|
export const logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo.commitinfo);
|
||||||
logger.enableConsole();
|
logger.enableConsole();
|
||||||
|
@ -2,6 +2,8 @@ import * as plugins from './plugins.js';
|
|||||||
|
|
||||||
export const cwd = process.cwd();
|
export const cwd = process.cwd();
|
||||||
|
|
||||||
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '..');
|
export const packageDir = plugins.path.join(
|
||||||
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
|
'..',
|
||||||
|
);
|
||||||
export const nogitDir = plugins.path.join(packageDir, '.nogit');
|
export const nogitDir = plugins.path.join(packageDir, '.nogit');
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// node native scope
|
// node native scope
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
export {
|
export { path };
|
||||||
path,
|
|
||||||
}
|
|
||||||
|
|
||||||
// @push.rocks scope
|
// @push.rocks scope
|
||||||
import * as smartfile from '@push.rocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
|
@ -6,9 +6,11 @@
|
|||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist_*/**/*.d.ts"
|
"dist_*/**/*.d.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
Reference in New Issue
Block a user