fix(config): rename npmextra configuration to .smartconfig.json and align publish packaging with updated config handling

This commit is contained in:
2026-03-24 19:05:22 +00:00
parent 58ae83f732
commit 9d6daa0430
10 changed files with 3143 additions and 3287 deletions

View File

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

View File

@@ -52,7 +52,7 @@ export class PublishModule {
...this.options.dependencies,
...(() => {
const resultDependencies = {};
for (const dependency of this.options.tsPublishJson.dependencies) {
for (const dependency of this.options.tsPublishJson!.dependencies) {
if (monoRepoPackageJson.dependencies[dependency]) {
resultDependencies[dependency] = monoRepoPackageJson.dependencies[dependency];
} else {
@@ -62,14 +62,14 @@ export class PublishModule {
return resultDependencies;
})(),
};
this.options.name = this.options.name || this.options.tsPublishJson.name;
this.options.name = this.options.name || this.options.tsPublishJson!.name;
this.options.version = monoRepoPackageJson.version;
// now that we have a name and version, lets check if there is already a package under the same name and version.
const smartnpmInstance = new plugins.smartnpm.NpmRegistry({}); // TODO: pass in options
let packageInfo: plugins.smartnpm.NpmPackage;
let packageInfo: plugins.smartnpm.NpmPackage | undefined;
try {
packageInfo = await smartnpmInstance.getPackageInfo(this.options.name);
packageInfo = await smartnpmInstance.getPackageInfo(this.options.name!);
} catch (error) {
logWarn(`Package ${this.options.name} does not yet seem to exist. Proceeding in 10 seconds...`);
await plugins.smartdelay.delayFor(10000);
@@ -77,7 +77,7 @@ export class PublishModule {
if (packageInfo) {
const availableVersions = packageInfo.allVersions.map((versionArg) => versionArg.version);
logInfo(`Available versions for ${this.options.name}: ${availableVersions.join(', ')}`);
if (availableVersions.includes(this.options.version)) {
if (availableVersions.includes(this.options.version!)) {
logError(
`Package ${this.options.name} already exists with version ${this.options.version}`
);
@@ -152,13 +152,13 @@ export class PublishModule {
'dist_ts_web/**/*',
'assets/**/*',
'cli.js',
'smartconfig.json',
'.smartconfig.json',
'readme.md',
],
...this.options.tsPublishJson.bin ? {
...this.options.tsPublishJson?.bin ? {
bin: (() => {
const binObject: {[key: string]: string} = {};
for (const bin of this.options.tsPublishJson.bin) {
for (const bin of this.options.tsPublishJson!.bin) {
binObject[bin] = `./cli.js`;
}
return binObject;
@@ -192,10 +192,10 @@ export class PublishModule {
// ts subfolder, the folder that contains the source code and is being transpiled
const destSubFolder = plugins.path.join(this.options.publishModDirFullPath, this.options.packageSubFolder);
await plugins.smartfs.directory(this.options.packageSubFolderFullPath).recursive().copy(destSubFolder);
await plugins.smartfs.directory(this.options.packageSubFolderFullPath!).recursive().copy(destSubFolder);
// readme
const readmeSrc = plugins.path.join(this.options.packageSubFolderFullPath, '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);
@@ -219,17 +219,17 @@ export class PublishModule {
public async createBinCliSetup() {
const binSetupApplies: boolean =
this.options.tsPublishJson.bin &&
Array.isArray(this.options.tsPublishJson.bin) &&
this.options.tsPublishJson.bin.length > 0;
!!this.options.tsPublishJson?.bin &&
Array.isArray(this.options.tsPublishJson!.bin) &&
this.options.tsPublishJson!.bin.length > 0;
const files = await this.tsPublishRef.giteaAssetsInstance.getFiles(
'git.zone',
'cli',
'assets/templates/cli/cli.js'
);
const indexPath = `./dist_${this.options.packageSubFolder}/index.js`;
const fileContent = atob(files[0].base64Content).replace('./dist_ts/index.js', indexPath);
const cliJsPath = plugins.path.join(this.options.publishModDirFullPath, 'cli.js');
const fileContent = atob(files[0].base64Content!).replace('./dist_ts/index.js', indexPath);
const cliJsPath = plugins.path.join(this.options.publishModDirFullPath!, 'cli.js');
await plugins.smartfs.file(cliJsPath).encoding('utf8').write(fileContent);
}