Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: copy yarn.lock to packages for deterministic builds #17218

Merged
merged 1 commit into from Jul 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 4 additions & 15 deletions scripts/binary/util/packages.js
Expand Up @@ -18,6 +18,7 @@ fs = Promise.promisifyAll(fs)
glob = Promise.promisify(glob)

const DEFAULT_PATHS = 'package.json'.split(' ')
const rootYarnLock = fs.readFileSync(path.join(__dirname, '../../../yarn.lock'), 'utf8')

const pathToPackageJson = function (packageFolder) {
la(check.unemptyString(packageFolder), 'expected package path', packageFolder)
Expand Down Expand Up @@ -181,14 +182,6 @@ const replaceLocalNpmVersions = function (basePath) {
return updatePackageJson('./packages/*/package.json')
}

const forceNpmInstall = function (packagePath, packageToInstall) {
console.log('Force installing %s', packageToInstall)
console.log('in %s', packagePath)
la(check.unemptyString(packageToInstall), 'missing package to install')

return yarn(['install', '--force', packageToInstall], packagePath)
}

const removeDevDependencies = function (packageFolder) {
const packagePath = pathToPackageJson(packageFolder)

Expand Down Expand Up @@ -252,6 +245,9 @@ const npmInstallAll = function (pathToPackages) {
return retryGlobbing(pathToPackages)
.tap(printFolders)
.mapSeries((packageFolder) => {
// Copying the yarn.lock from the root for deterministic builds
fs.writeFileSync(path.join(packageFolder, 'yarn.lock'), rootYarnLock)

return removeDevDependencies(packageFolder)
.then(() => {
return retryNpmInstall(packageFolder)
Expand All @@ -272,12 +268,5 @@ module.exports = {

runAllCleanJs,

forceNpmInstall,

replaceLocalNpmVersions,
}

if (!module.parent) {
console.log('demo force install')
forceNpmInstall('packages/server', '@ffmpeg-installer/win32-x64')
}