-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(publish): pin dependant versions of packages to current ones (#2263)
* ci(publish): pin dependant versions of packages to current ones * ci(publish): remove old file * refactor(publish): remove unnecessary variable
- Loading branch information
1 parent
8ddaa8a
commit dc13e3c
Showing
5 changed files
with
61 additions
and
25 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
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
58 changes: 58 additions & 0 deletions
58
.github/workflows/scripts/rename-packages-to-correct-version.js
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,58 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const packageJsonRelativePath = `../../../packages/${process.env.PACKAGE_FOLDER_NAME}/package.json`; | ||
const packageJsonFullPath = path.join(__dirname, packageJsonRelativePath); | ||
|
||
if (!fs.existsSync(packageJsonFullPath)) { | ||
throw new Error( | ||
`Path ${packageJsonRelativePath} does not exist! Please ensure you pass the correct PACKAGE_FOLDER_NAME environment variable. Perhaps your folder name has changed?` | ||
); | ||
} else { | ||
artilleryPackage = require(packageJsonRelativePath); | ||
} | ||
|
||
const updatePackageWithDependencies = (originalPackage) => { | ||
const packagesDir = '../../../packages'; | ||
const finalPackage = { ...originalPackage }; | ||
|
||
const packageFolders = fs | ||
.readdirSync(path.join(__dirname, packagesDir), { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
packageFolders.forEach((folder) => { | ||
const packageJsonRelativePath = `${packagesDir}/${folder}/package.json`; | ||
const packageJsonFullPath = path.join(__dirname, packageJsonRelativePath); | ||
|
||
if (!fs.existsSync(packageJsonFullPath)) { | ||
throw new Error( | ||
`Path ${packageJsonRelativePath} does not exist! Please ensure that it is a package!` | ||
); | ||
} | ||
|
||
const packageData = fs.readFileSync(packageJsonFullPath); | ||
const packageJson = JSON.parse(packageData); | ||
|
||
if ( | ||
finalPackage.dependencies[packageJson.name] && | ||
finalPackage.dependencies[packageJson.name] == '*' | ||
) { | ||
console.log( | ||
`Switching package ${packageJson.name} from ${ | ||
finalPackage.dependencies[packageJson.name] | ||
} to version ${packageJson.version}` | ||
); | ||
finalPackage.dependencies[packageJson.name] = packageJson.version; | ||
} | ||
}); | ||
|
||
return finalPackage; | ||
}; | ||
|
||
const modifiedPackage = updatePackageWithDependencies(artilleryPackage); | ||
|
||
fs.writeFileSync( | ||
`${packageJsonFullPath}`, | ||
JSON.stringify(modifiedPackage, null, 2) | ||
); |
This file was deleted.
Oops, something went wrong.