fix(mod_format): stop package.json formatter from modifying buildDocs and dependency entries
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-04-16 - 2.13.16 - fix(mod_format)
|
||||||
|
stop package.json formatter from modifying buildDocs and dependency entries
|
||||||
|
|
||||||
|
- removes automatic buildDocs script injection from the package.json formatter
|
||||||
|
- removes dependency include/exclude and latest-version update logic from package.json formatting
|
||||||
|
- drops the unused smartnpm plugin import after removing registry lookups
|
||||||
|
|
||||||
## 2026-03-24 - 2.13.15 - fix(repo)
|
## 2026-03-24 - 2.13.15 - fix(repo)
|
||||||
no changes to commit
|
no changes to commit
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/cli',
|
name: '@git.zone/cli',
|
||||||
version: '2.13.15',
|
version: '2.13.16',
|
||||||
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,77 +4,6 @@ import * as plugins from '../mod.plugins.js';
|
|||||||
import * as paths from '../../paths.js';
|
import * as paths from '../../paths.js';
|
||||||
import { logger, logVerbose } from '../../gitzone.logging.js';
|
import { logger, logVerbose } from '../../gitzone.logging.js';
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensures a certain dependency exists or is excluded
|
|
||||||
*/
|
|
||||||
const ensureDependency = async (
|
|
||||||
packageJsonObject: any,
|
|
||||||
position: 'dep' | 'devDep' | 'everywhere',
|
|
||||||
constraint: 'exclude' | 'include' | 'latest',
|
|
||||||
dependencyArg: string,
|
|
||||||
): Promise<void> => {
|
|
||||||
// Parse package name and version, handling scoped packages like @scope/name@version
|
|
||||||
const isScoped = dependencyArg.startsWith('@');
|
|
||||||
const lastAtIndex = dependencyArg.lastIndexOf('@');
|
|
||||||
|
|
||||||
// For scoped packages, the version @ must come after the /
|
|
||||||
// For unscoped packages, any @ indicates a version
|
|
||||||
const hasVersion = isScoped
|
|
||||||
? lastAtIndex > dependencyArg.indexOf('/')
|
|
||||||
: lastAtIndex >= 0;
|
|
||||||
|
|
||||||
const packageName = hasVersion ? dependencyArg.slice(0, lastAtIndex) : dependencyArg;
|
|
||||||
const version = hasVersion ? dependencyArg.slice(lastAtIndex + 1) : 'latest';
|
|
||||||
|
|
||||||
const targetSections: string[] = [];
|
|
||||||
|
|
||||||
switch (position) {
|
|
||||||
case 'dep':
|
|
||||||
targetSections.push('dependencies');
|
|
||||||
break;
|
|
||||||
case 'devDep':
|
|
||||||
targetSections.push('devDependencies');
|
|
||||||
break;
|
|
||||||
case 'everywhere':
|
|
||||||
targetSections.push('dependencies', 'devDependencies');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const section of targetSections) {
|
|
||||||
if (!packageJsonObject[section]) {
|
|
||||||
packageJsonObject[section] = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (constraint) {
|
|
||||||
case 'exclude':
|
|
||||||
delete packageJsonObject[section][packageName];
|
|
||||||
break;
|
|
||||||
case 'include':
|
|
||||||
if (!packageJsonObject[section][packageName]) {
|
|
||||||
packageJsonObject[section][packageName] =
|
|
||||||
version === 'latest' ? '^1.0.0' : version;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'latest':
|
|
||||||
try {
|
|
||||||
const registry = new plugins.smartnpm.NpmRegistry();
|
|
||||||
const packageInfo = await registry.getPackageInfo(packageName);
|
|
||||||
const latestVersion = packageInfo['dist-tags'].latest;
|
|
||||||
packageJsonObject[section][packageName] = `^${latestVersion}`;
|
|
||||||
} catch (error) {
|
|
||||||
logVerbose(
|
|
||||||
`Could not fetch latest version for ${packageName}, using existing or default`,
|
|
||||||
);
|
|
||||||
if (!packageJsonObject[section][packageName]) {
|
|
||||||
packageJsonObject[section][packageName] =
|
|
||||||
version === 'latest' ? '^1.0.0' : version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export class PackageJsonFormatter extends BaseFormatter {
|
export class PackageJsonFormatter extends BaseFormatter {
|
||||||
get name(): string {
|
get name(): string {
|
||||||
return 'packagejson';
|
return 'packagejson';
|
||||||
@@ -141,11 +70,6 @@ export class PackageJsonFormatter extends BaseFormatter {
|
|||||||
packageJson.scripts.build = `echo "Not needed for now"`;
|
packageJson.scripts.build = `echo "Not needed for now"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure buildDocs script exists
|
|
||||||
if (!packageJson.scripts.buildDocs) {
|
|
||||||
packageJson.scripts.buildDocs = `tsdoc`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set files array
|
// Set files array
|
||||||
packageJson.files = [
|
packageJson.files = [
|
||||||
'ts/**/*',
|
'ts/**/*',
|
||||||
@@ -160,21 +84,6 @@ export class PackageJsonFormatter extends BaseFormatter {
|
|||||||
'readme.md',
|
'readme.md',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Handle dependencies
|
|
||||||
await ensureDependency(
|
|
||||||
packageJson,
|
|
||||||
'devDep',
|
|
||||||
'exclude',
|
|
||||||
'@push.rocks/tapbundle',
|
|
||||||
);
|
|
||||||
await ensureDependency(packageJson, 'devDep', 'latest', '@git.zone/tstest');
|
|
||||||
await ensureDependency(
|
|
||||||
packageJson,
|
|
||||||
'devDep',
|
|
||||||
'latest',
|
|
||||||
'@git.zone/tsbuild',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set pnpm overrides from assets
|
// Set pnpm overrides from assets
|
||||||
try {
|
try {
|
||||||
const overridesContent = (await plugins.smartfs
|
const overridesContent = (await plugins.smartfs
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import * as smartfile from '@push.rocks/smartfile';
|
|||||||
import * as smartinteract from '@push.rocks/smartinteract';
|
import * as smartinteract from '@push.rocks/smartinteract';
|
||||||
import * as smartlegal from '@push.rocks/smartlegal';
|
import * as smartlegal from '@push.rocks/smartlegal';
|
||||||
import * as smartobject from '@push.rocks/smartobject';
|
import * as smartobject from '@push.rocks/smartobject';
|
||||||
import * as smartnpm from '@push.rocks/smartnpm';
|
|
||||||
import * as smartconfig from '@push.rocks/smartconfig';
|
import * as smartconfig from '@push.rocks/smartconfig';
|
||||||
import * as smartdiff from '@push.rocks/smartdiff';
|
import * as smartdiff from '@push.rocks/smartdiff';
|
||||||
import * as smartscaf from '@push.rocks/smartscaf';
|
import * as smartscaf from '@push.rocks/smartscaf';
|
||||||
@@ -16,7 +15,6 @@ export {
|
|||||||
smartinteract,
|
smartinteract,
|
||||||
smartlegal,
|
smartlegal,
|
||||||
smartobject,
|
smartobject,
|
||||||
smartnpm,
|
|
||||||
smartconfig,
|
smartconfig,
|
||||||
smartdiff,
|
smartdiff,
|
||||||
smartscaf,
|
smartscaf,
|
||||||
|
|||||||
Reference in New Issue
Block a user