diff --git a/lib/bump-cdk.ts b/lib/bump-cdk.ts index d92a994..44bda1c 100644 --- a/lib/bump-cdk.ts +++ b/lib/bump-cdk.ts @@ -32,16 +32,21 @@ async function processDependencies( if (debug) { console.log('processing'); } + const alphaVersion = `${version}-alpha.0`; let response = Object.assign({}, dependencies); for (const packageName in dependencies) { if (debug) { console.log(`Processing: ${packageName}`); } + const isAlphaPackage = packageName.includes('alpha'); const currentPackage = dependencies[packageName]; cdkPackagePatterns.forEach((pattern) => { if (packageName.match(pattern)) { - if (currentPackage === version) { + if ( + currentPackage === version || + (isAlphaPackage && currentPackage === alphaVersion) + ) { if (debug) { console.log(`${packageName} already up to date`); } @@ -50,11 +55,17 @@ async function processDependencies( if (debug) { console.log( - `Updating ${packageName}@${currentPackage} -> ${version}` + `Updating ${packageName}@${currentPackage} -> ${ + isAlphaPackage ? alphaVersion : version + }` ); } - response[packageName] = version; + if (isAlphaPackage) { + response[packageName] = alphaVersion; + } else { + response[packageName] = version; + } } }); } @@ -100,7 +111,7 @@ export async function bumpCdk( dependencyKeys .filter((key) => packageJson[key]) .map(async (key) => { - return new Promise(async (resolve, reject) => { + return new Promise(async (resolve, reject) => { try { if (debug) { console.log(`processing: ${key}`); @@ -120,9 +131,9 @@ export async function bumpCdk( ); const hasChanges = original !== packageJson; - + const formattedFile = JSON.stringify(packageJson, null, 2); - + if (!dryRun) { if (hasChanges) { if (debug) { diff --git a/package.json b/package.json index bf607a8..e96d8e7 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "package-json": "^6.5.0" }, "devDependencies": { + "@types/node": "^17.0.12", "prettier": "^2.0.5", "typescript": "^3.9.6" }, diff --git a/yarn.lock b/yarn.lock index f2493a7..9353b72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19,6 +19,11 @@ resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== +"@types/node@^17.0.12": + version "17.0.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.12.tgz#f7aa331b27f08244888c47b7df126184bc2339c5" + integrity sha512-4YpbAsnJXWYK/fpTVFlMIcUIho2AYCi4wg5aNPrG1ng7fn/1/RZfCIpRCiBX+12RVa34RluilnvCqD+g3KiSiA== + ansi-styles@^4.1.0: version "4.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"