-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle peer dependencies version
ISSUE CLOSED: #482
- Loading branch information
Showing
2 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import version from '../../version.json' assert {type: 'json'}; | ||
import {readJsonFile, writeJsonFile} from "nx/src/utils/fileutils.js"; | ||
|
||
const peerDeps = [ | ||
"@automapper/core", | ||
"@automapper/classes" | ||
]; | ||
|
||
const distRoot = 'dist/packages'; | ||
|
||
const distPackageJson = [ | ||
'classes', | ||
'classes/mapped-types', | ||
'classes/transformer-plugin', | ||
'core', | ||
'mikro', | ||
'nestjs', | ||
'pojos', | ||
'sequelize' | ||
] | ||
|
||
for (const path of distPackageJson) { | ||
const packageJsonPath = distRoot.concat('/', path, '/package.json'); | ||
try { | ||
const content = readJsonFile(packageJsonPath); | ||
for (const peerDep of peerDeps) { | ||
if (content['peerDependencies']?.[peerDep] && content['peerDependencies']?.[peerDep] !== version.version) { | ||
content['peerDependencies'][peerDep] = version.version; | ||
} | ||
} | ||
|
||
writeJsonFile(packageJsonPath, content); | ||
} catch (e) { | ||
console.error(`Error processing json file: ${path}`); | ||
console.error(e); | ||
} | ||
} |