Skip to content

Commit

Permalink
feat(build): Add utility for package bumps
Browse files Browse the repository at this point in the history
Adding a temporary utility script that shall be used to bump packages to the latest version across
all spinnaker packages until lerna migration is complete.
  • Loading branch information
vigneshm committed Jun 11, 2021
1 parent 78497fd commit 07cecb5
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions app/scripts/modules/bumpPackage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env node

/**
* A temporary utility script that shall be used to bump packages to the latest version across all spinnaker packages
* until lerna migration is complete.
*/

/* eslint-disable no-console */
const { execSync } = require('child_process');
const { readFileSync } = require('fs');
const path = require('path');

if (process.argv.length < 3) {
console.log('Error: package name must be provided like `./bumpPackage.js package` ');
process.exit(1);
}

const packageToUpgrade = process.argv[2];

const packages = [
'.',
'app/scripts/modules/amazon/',
'app/scripts/modules/appengine/',
'app/scripts/modules/azure/',
'app/scripts/modules/cloudfoundry/',
'app/scripts/modules/core/',
'app/scripts/modules/docker/',
'app/scripts/modules/ecs/',
'app/scripts/modules/google/',
'app/scripts/modules/huaweicloud/',
'app/scripts/modules/kubernetes/',
'app/scripts/modules/oracle/',
'app/scripts/modules/tencentcloud/',
'app/scripts/modules/titus/',
'packages/eslint-plugin/',
'packages/mocks/',
'packages/pluginsdk/',
'packages/pluginsdk/scaffold/',
'packages/pluginsdk-peerdeps/',
'packages/presentation/',
'packages/scripts/',
'test/functional/',
];

packages
.map((packagePath) => path.resolve(__dirname, '../../../', packagePath))
.filter((packagePath) => {
const packageJSON = JSON.parse(readFileSync(path.resolve(packagePath, 'package.json'), 'utf8'));

return (
packageToUpgrade in (packageJSON.dependencies || {}) || packageToUpgrade in (packageJSON.devDependencies || {})
);
})
.forEach((package) => {
console.log(`Handling ${package}`);
console.log();

const yarnCmd = `yarn --cwd ${package}`;
console.log(yarnCmd);
console.log();
console.log(execSync(yarnCmd).toString());

const yarnUpgradeCmd = `yarn --cwd ${package} upgrade --latest ${packageToUpgrade}`;
console.log(yarnUpgradeCmd);
console.log();
console.log(execSync(yarnUpgradeCmd).toString());
console.log('===============================');
console.log();
});

0 comments on commit 07cecb5

Please sign in to comment.