check-dependency-version-consistency
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -8,2 +8,16 @@ # check-dependency-version-consistency | ||
## v1.4.1 (2021-10-28) | ||
#### :bug: Bug Fix | ||
* [#241](https://github.com/bmish/check-dependency-version-consistency/pull/241) Don't ignore workspace root package.json ([@bmish](https://github.com/bmish)) | ||
* [#242](https://github.com/bmish/check-dependency-version-consistency/pull/242) Maintain newline at end of package.json file ([@bmish](https://github.com/bmish)) | ||
#### :house: Internal | ||
* [#243](https://github.com/bmish/check-dependency-version-consistency/pull/243) Test under Node 17 ([@bmish](https://github.com/bmish)) | ||
#### Committers: 1 | ||
- Bryan Mishkin ([@bmish](https://github.com/bmish)) | ||
## v1.4.0 (2021-10-12) | ||
@@ -10,0 +24,0 @@ |
@@ -107,3 +107,5 @@ import { readFileSync, existsSync } from 'node:fs'; | ||
for (const packageJsonPath of packageJsonPaths) { | ||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')); | ||
const packageJsonContents = readFileSync(packageJsonPath, 'utf-8'); | ||
const packageJsonEndsInNewline = packageJsonContents.endsWith('\n'); | ||
const packageJson = JSON.parse(packageJsonContents); | ||
if (packageJson.devDependencies && | ||
@@ -115,2 +117,3 @@ packageJson.devDependencies[mismatchingVersion.dependency] && | ||
autosave: true, | ||
stringify_eol: packageJsonEndsInNewline, // If a newline at end of file exists, keep it. | ||
}); | ||
@@ -126,2 +129,3 @@ packageJsonEditor.set(`devDependencies.${mismatchingVersion.dependency.replace(/\./g, // Escape dots. | ||
autosave: true, | ||
stringify_eol: packageJsonEndsInNewline, // If a newline at end of file exists, keep it. | ||
}); | ||
@@ -128,0 +132,0 @@ packageJsonEditor.set(`dependencies.${mismatchingVersion.dependency.replace(/\./g, // Escape dots. |
@@ -18,5 +18,6 @@ import chalk from 'chalk'; | ||
const usageCount = versionObj.packages.length; | ||
const packages = usageCount > 3 | ||
? `${versionObj.packages.slice(0, 3).join(', ')}, and ${usageCount - 3} other${usageCount - 3 === 1 ? '' : 's'}` | ||
: versionObj.packages.join(', '); | ||
const packageNames = versionObj.packages.map((pkg) => pkg === '.' ? '(Root)' : pkg); | ||
const packageListSentence = usageCount > 3 | ||
? `${packageNames.slice(0, 3).join(', ')}, and ${usageCount - 3} other${usageCount - 3 === 1 ? '' : 's'}` | ||
: packageNames.join(', '); | ||
return [ | ||
@@ -28,3 +29,3 @@ chalk.redBright(versionObj.version), | ||
: usageCount, | ||
packages, | ||
packageListSentence, | ||
]; | ||
@@ -31,0 +32,0 @@ }); |
@@ -8,3 +8,3 @@ import { join } from 'node:path'; | ||
function getPackages(root) { | ||
return getWorkspaces(root).flatMap((packageLocation) => { | ||
const workspacePackages = getWorkspaces(root).flatMap((packageLocation) => { | ||
if (packageLocation.includes('*')) { | ||
@@ -18,2 +18,3 @@ const packageLocationWithoutStar = packageLocation.replace('*', ''); | ||
}); | ||
return ['.', ...workspacePackages]; // Include workspace root. | ||
} | ||
@@ -20,0 +21,0 @@ export function getWorkspaces(root) { |
@@ -190,5 +190,5 @@ import { readFileSync, existsSync } from 'node:fs'; | ||
for (const packageJsonPath of packageJsonPaths) { | ||
const packageJson: PackageJson = JSON.parse( | ||
readFileSync(packageJsonPath, 'utf-8') | ||
); | ||
const packageJsonContents = readFileSync(packageJsonPath, 'utf-8'); | ||
const packageJsonEndsInNewline = packageJsonContents.endsWith('\n'); | ||
const packageJson: PackageJson = JSON.parse(packageJsonContents); | ||
@@ -203,2 +203,3 @@ if ( | ||
autosave: true, | ||
stringify_eol: packageJsonEndsInNewline, // If a newline at end of file exists, keep it. | ||
}); | ||
@@ -222,2 +223,3 @@ packageJsonEditor.set( | ||
autosave: true, | ||
stringify_eol: packageJsonEndsInNewline, // If a newline at end of file exists, keep it. | ||
}); | ||
@@ -224,0 +226,0 @@ packageJsonEditor.set( |
@@ -29,8 +29,11 @@ import chalk from 'chalk'; | ||
const usageCount = versionObj.packages.length; | ||
const packages = | ||
const packageNames = versionObj.packages.map((pkg) => | ||
pkg === '.' ? '(Root)' : pkg | ||
); | ||
const packageListSentence = | ||
usageCount > 3 | ||
? `${versionObj.packages.slice(0, 3).join(', ')}, and ${ | ||
? `${packageNames.slice(0, 3).join(', ')}, and ${ | ||
usageCount - 3 | ||
} other${usageCount - 3 === 1 ? '' : 's'}` | ||
: versionObj.packages.join(', '); | ||
: packageNames.join(', '); | ||
return [ | ||
@@ -42,3 +45,3 @@ chalk.redBright(versionObj.version), | ||
: usageCount, | ||
packages, | ||
packageListSentence, | ||
]; | ||
@@ -45,0 +48,0 @@ }); |
@@ -13,12 +13,15 @@ import { join } from 'node:path'; | ||
function getPackages(root: string): string[] { | ||
return getWorkspaces(root).flatMap((packageLocation: string) => { | ||
if (packageLocation.includes('*')) { | ||
const packageLocationWithoutStar = packageLocation.replace('*', ''); | ||
return getDirectoriesInPath(join(root, packageLocationWithoutStar)).map( | ||
(pkg) => join(packageLocationWithoutStar, pkg) | ||
); | ||
} else { | ||
return packageLocation; | ||
const workspacePackages = getWorkspaces(root).flatMap( | ||
(packageLocation: string) => { | ||
if (packageLocation.includes('*')) { | ||
const packageLocationWithoutStar = packageLocation.replace('*', ''); | ||
return getDirectoriesInPath(join(root, packageLocationWithoutStar)).map( | ||
(pkg) => join(packageLocationWithoutStar, pkg) | ||
); | ||
} else { | ||
return packageLocation; | ||
} | ||
} | ||
}); | ||
); | ||
return ['.', ...workspacePackages]; // Include workspace root. | ||
} | ||
@@ -25,0 +28,0 @@ |
{ | ||
"name": "check-dependency-version-consistency", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Ensures dependencies are on consistent versions across a monorepo.", | ||
@@ -55,7 +55,7 @@ "keywords": [ | ||
"@types/semver": "^7.3.8", | ||
"@typescript-eslint/eslint-plugin": "^4.0.1", | ||
"@typescript-eslint/parser": "^4.0.1", | ||
"eslint": "^7.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.2.0", | ||
"@typescript-eslint/parser": "^5.2.0", | ||
"eslint": "^8.1.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-square": "^20.0.2", | ||
"eslint-plugin-square": "^21.0.0", | ||
"markdownlint-cli": "^0.29.0", | ||
@@ -68,3 +68,3 @@ "mocha": "^9.1.1", | ||
"release-it": "^14.2.2", | ||
"release-it-lerna-changelog": "^3.1.0", | ||
"release-it-lerna-changelog": "^4.0.1", | ||
"sort-package-json": "^1.44.0", | ||
@@ -71,0 +71,0 @@ "ts-node": "^10.2.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45978
838