Skip to content

Instantly share code, notes, and snippets.

@ranyitz
Last active March 10, 2020 11:44
Show Gist options
  • Save ranyitz/f595b72098477ab2146d64f984ac865f to your computer and use it in GitHub Desktop.
Save ranyitz/f595b72098477ab2146d64f984ac865f to your computer and use it in GitHub Desktop.
yoshi release to fed ci release migration script
{
"name": "yoshi-release-to-fed-ci-release",
"version": "1.0.0",
"bin": "./yoshi-release-to-fed-ci-release.js"
}
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const packageJsonPath = path.join(process.cwd(), 'package.json');
const pkg = require(packageJsonPath);
const shouldRemoveRelease = pkg.scripts.release;
const hasVersionBumpStrategy = pkg.publishConfig && pkg.publishConfig.versionBumpStrategy;
const shouldWriteVersionBumpStrategy = pkg.publishConfig && !hasVersionBumpStrategy;
if (shouldRemoveRelease) {
delete pkg.scripts.release;
console.info('> Removing release script');
}
if (shouldWriteVersionBumpStrategy) {
pkg.publishConfig.versionBumpStrategy = 'minor';
console.info('> Adding publishConfig.versionBumpStrategy: "minor"');
}
if(!shouldWriteVersionBumpStrategy && !shouldRemoveRelease) {
console.log();
console.info('✔︎ No changes has been made, you are up to date');
} else {
fs.writeFileSync('./package.json', JSON.stringify(pkg ,null, 2));
console.info('> Write package.json with the above changes');
console.log();
console.info('✔︎ Migration passed succesfully');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment