Last active
March 10, 2020 11:44
-
-
Save ranyitz/f595b72098477ab2146d64f984ac865f to your computer and use it in GitHub Desktop.
yoshi release to fed ci release migration script
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
{ | |
"name": "yoshi-release-to-fed-ci-release", | |
"version": "1.0.0", | |
"bin": "./yoshi-release-to-fed-ci-release.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
#!/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