Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
4ee31f85ab | |||
2b518722df | |||
5f9bd73904 | |||
91f3c90607 | |||
f518670443 | |||
dc97693ec8 | |||
386504b0fb | |||
a7c631bba1 | |||
5922249742 | |||
274b730492 | |||
5bdc3e8bcc | |||
5389034108 |
34
changelog.md
34
changelog.md
@ -1,5 +1,39 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-10-28 - 1.5.1 - fix(core)
|
||||||
|
Fixes handling of undefined paths in tsconfig generation.
|
||||||
|
|
||||||
|
- Added a null check for `paths` in the original tsconfig before modifying it.
|
||||||
|
- Enhanced testing by adding a test case for creating a TsPublish instance.
|
||||||
|
|
||||||
|
## 2024-10-28 - 1.5.0 - feat(classes.publishmodule)
|
||||||
|
Add method to create and write tsconfig.json during publish module setup
|
||||||
|
|
||||||
|
- Introduced createTsconfigJson method in PublishModule class to generate a tsconfig.json for each publishable module.
|
||||||
|
- Modified createPublishModuleDir method to include writing of tsconfig.json file.
|
||||||
|
|
||||||
|
## 2024-10-26 - 1.4.0 - feat(core)
|
||||||
|
Refactor directory reading and module discovery for publishing process
|
||||||
|
|
||||||
|
- Renamed 'readDirectory' method to 'getModuleSubDirs' for clarity in describing function purpose.
|
||||||
|
- Enhanced 'getModuleSubDirs' to return module information including parsed 'tspublish.json' data for each module.
|
||||||
|
- Introduced new 'interfaces' directory to define TypeScript interfaces like 'ITsPublishJson'.
|
||||||
|
|
||||||
|
## 2024-10-23 - 1.3.3 - fix(core)
|
||||||
|
Fix logging mechanism on existing package version check
|
||||||
|
|
||||||
|
- Changed the error handling mechanism when a package with the same version already exists to use logger and process exit instead of throwing an error.
|
||||||
|
|
||||||
|
## 2024-10-23 - 1.3.2 - fix(core)
|
||||||
|
Corrected file patterns in dynamically created package.json files.
|
||||||
|
|
||||||
|
- Fixed incorrect file pattern from 'ts_web/**/*' to 'ts_*/**/*' in package.json creation process to include all subdirectories starting with 'ts'.
|
||||||
|
|
||||||
|
## 2024-10-23 - 1.3.1 - fix(classes.publishmodule)
|
||||||
|
Fix template string in createPackageJson method for export path
|
||||||
|
|
||||||
|
- Corrected the syntax for template string in the exports path of created package.json
|
||||||
|
|
||||||
## 2024-10-21 - 1.3.0 - feat(core)
|
## 2024-10-21 - 1.3.0 - feat(core)
|
||||||
Add support for multiple registries in the publish process
|
Add support for multiple registries in the publish process
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tspublish",
|
"name": "@git.zone/tspublish",
|
||||||
"version": "1.3.0",
|
"version": "1.5.1",
|
||||||
"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",
|
||||||
|
7192
pnpm-lock.yaml
generated
7192
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -5,4 +5,9 @@ tap.test('first test', async () => {
|
|||||||
console.log(tspublish);
|
console.log(tspublish);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should create a TsPublish instance', async () => {
|
||||||
|
const tspublishInstance = new tspublish.TsPublish();
|
||||||
|
expect(tspublishInstance).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tspublish',
|
name: '@git.zone/tspublish',
|
||||||
version: '1.3.0',
|
version: '1.5.1',
|
||||||
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.'
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,8 @@ 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)) {
|
||||||
throw new Error(
|
logger.log('error', `package ${this.options.name} already exists with version ${this.options.version}`);
|
||||||
`package ${this.options.name} already exists with version ${this.options.version}`
|
process.exit(1);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,6 +76,33 @@ export class PublishModule {
|
|||||||
return packageInfo.allVersions[0].version;
|
return packageInfo.allVersions[0].version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async createTsconfigJson() {
|
||||||
|
const originalTsConfig = plugins.smartfile.fs.toObjectSync(
|
||||||
|
plugins.path.join(paths.cwd, 'tsconfig.json')
|
||||||
|
);
|
||||||
|
if (originalTsConfig?.compilerOptions?.paths) {
|
||||||
|
for (const path of originalTsConfig.compilerOptions.paths) {
|
||||||
|
originalTsConfig.compilerOptions.paths[path][0] = `.${originalTsConfig.compilerOptions.paths[path][0]}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const tsconfigJson = {
|
||||||
|
compilerOptions: {
|
||||||
|
experimentalDecorators: true,
|
||||||
|
useDefineForClassFields: false,
|
||||||
|
target: 'ES2022',
|
||||||
|
module: 'NodeNext',
|
||||||
|
moduleResolution: 'NodeNext',
|
||||||
|
esModuleInterop: true,
|
||||||
|
verbatimModuleSyntax: true,
|
||||||
|
paths: originalTsConfig?.compilerOptions?.paths,
|
||||||
|
},
|
||||||
|
exclude: [
|
||||||
|
'dist_*/**/*.d.ts',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
return JSON.stringify(tsconfigJson, null, 2);
|
||||||
|
}
|
||||||
|
|
||||||
public async createPackageJson() {
|
public async createPackageJson() {
|
||||||
const packageJson = {
|
const packageJson = {
|
||||||
name: this.options.name,
|
name: this.options.name,
|
||||||
@ -85,7 +111,7 @@ export class PublishModule {
|
|||||||
description: '',
|
description: '',
|
||||||
exports: {
|
exports: {
|
||||||
'.': {
|
'.': {
|
||||||
import: './dist_${this.options.packageSubFolder}/index.js',
|
import: `./dist_${this.options.packageSubFolder}/index.js`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
scripts: {
|
scripts: {
|
||||||
@ -97,7 +123,7 @@ export class PublishModule {
|
|||||||
},
|
},
|
||||||
files: [
|
files: [
|
||||||
'ts/**/*',
|
'ts/**/*',
|
||||||
'ts_web/**/*',
|
'ts_*/**/*',
|
||||||
'dist/**/*',
|
'dist/**/*',
|
||||||
'dist_*/**/*',
|
'dist_*/**/*',
|
||||||
'dist_ts/**/*',
|
'dist_ts/**/*',
|
||||||
@ -126,6 +152,14 @@ export class PublishModule {
|
|||||||
);
|
);
|
||||||
await packageJson.write();
|
await packageJson.write();
|
||||||
|
|
||||||
|
// tsconfig.json
|
||||||
|
const originalTsConfigJson = await plugins.smartfile.SmartFile.fromString(
|
||||||
|
plugins.path.join(this.options.publishModDirFullPath, 'tsconfig.json'),
|
||||||
|
await this.createTsconfigJson(),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
await originalTsConfigJson.write();
|
||||||
|
|
||||||
// ts folder
|
// ts folder
|
||||||
await plugins.smartfile.fs.copy(
|
await plugins.smartfile.fs.copy(
|
||||||
this.options.packageSubFolderFullPath,
|
this.options.packageSubFolderFullPath,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { logger } from './logging.js';
|
import { logger } from './logging.js';
|
||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
import { PublishModule } from './classes.publishmodule.js';
|
import { PublishModule } from './classes.publishmodule.js';
|
||||||
|
|
||||||
@ -7,8 +8,8 @@ export class TsPublish {
|
|||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
public async publish (monorepoDirArg: string) {
|
public async publish (monorepoDirArg: string) {
|
||||||
const publishModules = await this.readDirectory(monorepoDirArg);
|
const publishModules = await this.getModuleSubDirs(monorepoDirArg);
|
||||||
for (const publishModule of publishModules) {
|
for (const publishModule of Object.keys(publishModules)) {
|
||||||
const publishModuleInstance = new PublishModule({
|
const publishModuleInstance = new PublishModule({
|
||||||
monoRepoDir: monorepoDirArg,
|
monoRepoDir: monorepoDirArg,
|
||||||
packageSubFolder: publishModule,
|
packageSubFolder: publishModule,
|
||||||
@ -20,9 +21,9 @@ export class TsPublish {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async readDirectory (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: string[] = [];
|
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;
|
||||||
@ -33,7 +34,7 @@ export class TsPublish {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
logger.log('info', `found publish module: ${subDir}`);
|
logger.log('info', `found publish module: ${subDir}`);
|
||||||
publishModules.push(subDir);
|
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
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './tspublish.js';
|
5
ts/interfaces/tspublish.ts
Normal file
5
ts/interfaces/tspublish.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface ITsPublishJson {
|
||||||
|
name: string;
|
||||||
|
dependencies: string[];
|
||||||
|
registries: string[];
|
||||||
|
}
|
Reference in New Issue
Block a user