beachball
Advanced tools
Comparing version 1.13.4 to 1.13.5
@@ -5,3 +5,24 @@ { | ||
{ | ||
"date": "Wed, 25 Sep 2019 21:40:45 GMT", | ||
"date": "Fri, 27 Sep 2019 23:42:40 GMT", | ||
"tag": "beachball_v1.13.5", | ||
"version": "1.13.5", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"comment": "fix a clean up routine in test fixture for repositories", | ||
"author": "odbuild@microsoft.com", | ||
"commit": "13610e182b36fc99a66c8d0a55e309fbd63857f3" | ||
} | ||
], | ||
"patch": [ | ||
{ | ||
"comment": "adds publish test for git push as well as refactoring publish to be more readable", | ||
"author": "odbuild@microsoft.com", | ||
"commit": "085a15a91e592e7119c9a3d1222b781e197f1bd7" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Wed, 25 Sep 2019 21:40:51 GMT", | ||
"tag": "beachball_v1.13.4", | ||
@@ -8,0 +29,0 @@ "version": "1.13.4", |
# Change Log - beachball | ||
This log was last generated on Wed, 25 Sep 2019 21:40:45 GMT and should not be manually modified. | ||
This log was last generated on Fri, 27 Sep 2019 23:42:40 GMT and should not be manually modified. | ||
## 1.13.5 | ||
Fri, 27 Sep 2019 23:42:40 GMT | ||
### Patches | ||
- adds publish test for git push as well as refactoring publish to be more readable (odbuild@microsoft.com) | ||
## 1.13.4 | ||
Wed, 25 Sep 2019 21:40:45 GMT | ||
Wed, 25 Sep 2019 21:40:51 GMT | ||
@@ -8,0 +14,0 @@ ### Patches |
@@ -23,3 +23,3 @@ "use strict"; | ||
}); | ||
describe('packagePublish', () => { | ||
describe('npm publish', () => { | ||
beforeEach(() => __awaiter(this, void 0, void 0, function* () { | ||
@@ -26,0 +26,0 @@ yield registry.reset(); |
import * as tmp from 'tmp'; | ||
export declare const packageJsonFixture: { | ||
name: string; | ||
version: string; | ||
}; | ||
export declare class RepositoryFactory { | ||
@@ -8,2 +12,3 @@ root?: tmp.DirResult; | ||
export declare class Repository { | ||
origin?: string; | ||
root?: tmp.DirResult; | ||
@@ -10,0 +15,0 @@ initialize(): Promise<void>; |
@@ -29,6 +29,6 @@ "use strict"; | ||
const removeAsync = util_1.promisify(fs.remove); | ||
const packageJson = JSON.stringify({ | ||
exports.packageJsonFixture = { | ||
name: 'foo', | ||
version: '1.0.0', | ||
}); | ||
}; | ||
function dirAsync(options) { | ||
@@ -90,13 +90,2 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
function touchAsync(filename) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const time = new Date(); | ||
try { | ||
yield fs.utimes(filename, time, time); | ||
} | ||
catch (err) { | ||
yield fs.close(yield fs.open(filename, 'w')); | ||
} | ||
}); | ||
} | ||
class RepositoryFactory { | ||
@@ -113,3 +102,3 @@ create() { | ||
yield tmpRepo.commitChange('README'); | ||
yield writeFileAsync(path_1.default.join(tmpRepo.rootPath, 'package.json'), packageJson); | ||
yield writeFileAsync(path_1.default.join(tmpRepo.rootPath, 'package.json'), JSON.stringify(exports.packageJsonFixture, null, 2)); | ||
yield tmpRepo.commitChange('package.json'); | ||
@@ -155,2 +144,3 @@ yield tmpRepo.push('origin', 'HEAD:master'); | ||
]); | ||
this.origin = path; | ||
}); | ||
@@ -163,7 +153,4 @@ } | ||
} | ||
yield touchAsync(path_1.default.join(this.root.name, newFilename)); | ||
yield runInDirectory(this.root.name, [ | ||
`git add ${newFilename}`, | ||
`git commit -m '${newFilename}'`, | ||
]); | ||
yield fs.ensureFile(path_1.default.join(this.root.name, newFilename)); | ||
yield runInDirectory(this.root.name, [`git add ${newFilename}`, `git commit -m '${newFilename}'`]); | ||
}); | ||
@@ -192,3 +179,3 @@ } | ||
} | ||
//await removeAsync(this.root.name); | ||
yield removeAsync(this.root.name); | ||
}); | ||
@@ -195,0 +182,0 @@ } |
@@ -20,5 +20,70 @@ "use strict"; | ||
const changefile_1 = require("./changefile"); | ||
function publishToRegistry(options) { | ||
const { path: cwd, registry, tag, token, access } = options; | ||
console.log('Bumping version for npm publish'); | ||
const bumpInfo = bump_1.bump(cwd); | ||
if (!validatePackageVersions(bumpInfo, registry)) { | ||
displayManualRecovery(bumpInfo); | ||
console.error('No packages have been published'); | ||
process.exit(1); | ||
} | ||
Object.keys(bumpInfo.packageChangeTypes).forEach(pkg => { | ||
const packageInfo = bumpInfo.packageInfos[pkg]; | ||
console.log(`Publishing - ${packageInfo.name}@${packageInfo.version}`); | ||
const result = packageManager_1.packagePublish(packageInfo, registry, token, tag, access); | ||
if (result.success) { | ||
console.log('Published!'); | ||
} | ||
else { | ||
displayManualRecovery(bumpInfo); | ||
console.error(result.stderr); | ||
process.exit(1); | ||
return; | ||
} | ||
}); | ||
console.log('Reverting'); | ||
git_1.revertLocalChanges(cwd); | ||
} | ||
function bumpAndPush(publishBranch, options) { | ||
const { path: cwd, branch, tag, message } = options; | ||
const { remote, remoteBranch } = git_1.parseRemoteBranch(branch); | ||
console.log('Fetching from remote'); | ||
// pull in latest from origin branch | ||
git_1.gitFailFast(['fetch', remote], { cwd }); | ||
const mergeResult = git_1.git(['merge', '-X', 'theirs', `${branch}`], { cwd }); | ||
if (!mergeResult.success) { | ||
console.error(`CRITICAL ERROR: pull from ${branch} has failed!`); | ||
console.error(mergeResult.stderr); | ||
process.exit(1); | ||
} | ||
// bump the version | ||
console.log('Bumping the versions for git push'); | ||
const bumpInfo = bump_1.bump(cwd); | ||
// checkin | ||
const mergePublishBranchResult = mergePublishBranch(publishBranch, branch, message, cwd); | ||
if (!mergePublishBranchResult.success) { | ||
console.error('CRITICAL ERROR: merging to target has failed!'); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
// Step 3. Tag & Push to remote | ||
tagPackages(bumpInfo, tag, cwd); | ||
console.log(`pushing to ${branch}, running the following command for git push:`); | ||
const pushArgs = ['push', '--no-verify', '--follow-tags', '--verbose', remote, `HEAD:${remoteBranch}`]; | ||
console.log('git ' + pushArgs.join(' ')); | ||
const pushResult = git_1.git(pushArgs, { cwd }); | ||
if (!pushResult.success) { | ||
console.error(`CRITICAL ERROR: push to ${branch} has failed!`); | ||
console.error(pushResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
else { | ||
console.log(pushResult.stdout.toString()); | ||
console.log(pushResult.stderr.toString()); | ||
} | ||
} | ||
function publish(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { path: cwd, branch, registry, tag, token, message, access } = options; | ||
const { path: cwd, branch, registry, tag, message } = options; | ||
// First, validate that we have changes to publish | ||
@@ -58,26 +123,5 @@ const packageChangeTypes = changefile_1.getPackageChangeTypes(cwd); | ||
// Step 1. Bump + npm publish | ||
// bump the version | ||
console.log('Bumping version for npm publish'); | ||
const bumpInfo = bump_1.bump(cwd); | ||
if (!validatePackageVersions(bumpInfo, registry)) { | ||
displayManualRecovery(bumpInfo); | ||
console.error('No packages have been published'); | ||
process.exit(1); | ||
} | ||
// npm / yarn publish | ||
if (options.publish) { | ||
Object.keys(bumpInfo.packageChangeTypes).forEach(pkg => { | ||
const packageInfo = bumpInfo.packageInfos[pkg]; | ||
console.log(`Publishing - ${packageInfo.name}@${packageInfo.version}`); | ||
const result = packageManager_1.packagePublish(packageInfo, registry, token, tag, access); | ||
if (result.success) { | ||
console.log('Published!'); | ||
} | ||
else { | ||
displayManualRecovery(bumpInfo); | ||
console.error(result.stderr); | ||
process.exit(1); | ||
return; | ||
} | ||
}); | ||
publishToRegistry(options); | ||
} | ||
@@ -89,40 +133,7 @@ else { | ||
// - reset, fetch latest from origin/master (to ensure less chance of conflict), then bump again + commit | ||
if (!branch || !options.push) { | ||
console.log('Skipping git push and tagging'); | ||
if (branch && options.push) { | ||
bumpAndPush(publishBranch, options); | ||
} | ||
else { | ||
const { remote, remoteBranch } = git_1.parseRemoteBranch(branch); | ||
console.log('Reverting and fetching from remote'); | ||
// pull in latest from origin branch | ||
git_1.revertLocalChanges(cwd); | ||
git_1.gitFailFast(['fetch', remote], { cwd }); | ||
const mergeResult = git_1.git(['merge', '-X', 'theirs', `${branch}`], { cwd }); | ||
if (!mergeResult.success) { | ||
console.error(`CRITICAL ERROR: pull from ${branch} has failed!`); | ||
console.error(mergeResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
// bump the version | ||
console.log('Bumping the versions for git push'); | ||
bump_1.bump(cwd); | ||
// checkin | ||
const mergePublishBranchResult = mergePublishBranch(publishBranch, branch, message, cwd); | ||
if (!mergePublishBranchResult.success) { | ||
console.error('CRITICAL ERROR: merging to target has failed!'); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
// Step 3. Tag & Push to remote | ||
tagPackages(bumpInfo, tag, cwd); | ||
console.log(`pushing to ${branch}, running the following command for git push:`); | ||
const pushArgs = ['push', '--no-verify', '--follow-tags', '--verbose', remote, `HEAD:${remoteBranch}`]; | ||
console.log('git ' + pushArgs.join(' ')); | ||
const pushResult = git_1.git(pushArgs); | ||
if (!pushResult.success) { | ||
console.error(`CRITICAL ERROR: push to ${branch} has failed!`); | ||
console.error(pushResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
console.log('Skipping git push and tagging'); | ||
} | ||
@@ -129,0 +140,0 @@ if (currentBranch) { |
{ | ||
"name": "beachball", | ||
"version": "1.13.4", | ||
"version": "1.13.5", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -17,3 +17,3 @@ import { Registry } from '../fixtures/registry'; | ||
describe('packagePublish', () => { | ||
describe('npm publish', () => { | ||
beforeEach(async () => { | ||
@@ -20,0 +20,0 @@ await registry.reset(); |
@@ -11,6 +11,6 @@ import { exec as nativeExec } from 'child_process'; | ||
const packageJson = JSON.stringify({ | ||
export const packageJsonFixture = { | ||
name: 'foo', | ||
version: '1.0.0', | ||
}); | ||
}; | ||
@@ -74,12 +74,2 @@ async function dirAsync(options: tmp.DirOptions): Promise<tmp.DirResult> { | ||
async function touchAsync(filename:string) { | ||
const time = new Date(); | ||
try { | ||
await fs.utimes(filename, time, time); | ||
} catch (err) { | ||
await fs.close(await fs.open(filename, 'w')); | ||
} | ||
} | ||
export class RepositoryFactory { | ||
@@ -100,3 +90,3 @@ root?: tmp.DirResult; | ||
await writeFileAsync(path.join(tmpRepo.rootPath, 'package.json'), packageJson); | ||
await writeFileAsync(path.join(tmpRepo.rootPath, 'package.json'), JSON.stringify(packageJsonFixture, null, 2)); | ||
await tmpRepo.commitChange('package.json'); | ||
@@ -120,2 +110,4 @@ await tmpRepo.push('origin', 'HEAD:master'); | ||
export class Repository { | ||
origin?: string; | ||
root?: tmp.DirResult; | ||
@@ -144,2 +136,4 @@ | ||
]); | ||
this.origin = path; | ||
} | ||
@@ -152,8 +146,5 @@ | ||
await touchAsync(path.join(this.root.name, newFilename)); | ||
await fs.ensureFile(path.join(this.root.name, newFilename)); | ||
await runInDirectory(this.root.name, [ | ||
`git add ${newFilename}`, | ||
`git commit -m '${newFilename}'`, | ||
]); | ||
await runInDirectory(this.root.name, [`git add ${newFilename}`, `git commit -m '${newFilename}'`]); | ||
} | ||
@@ -181,4 +172,4 @@ | ||
//await removeAsync(this.root.name); | ||
await removeAsync(this.root.name); | ||
} | ||
} |
@@ -9,4 +9,79 @@ import { bump, BumpInfo } from './bump'; | ||
function publishToRegistry(options: CliOptions) { | ||
const { path: cwd, registry, tag, token, access } = options; | ||
console.log('Bumping version for npm publish'); | ||
const bumpInfo = bump(cwd); | ||
if (!validatePackageVersions(bumpInfo, registry)) { | ||
displayManualRecovery(bumpInfo); | ||
console.error('No packages have been published'); | ||
process.exit(1); | ||
} | ||
Object.keys(bumpInfo.packageChangeTypes).forEach(pkg => { | ||
const packageInfo = bumpInfo.packageInfos[pkg]; | ||
console.log(`Publishing - ${packageInfo.name}@${packageInfo.version}`); | ||
const result = packagePublish(packageInfo, registry, token, tag, access); | ||
if (result.success) { | ||
console.log('Published!'); | ||
} else { | ||
displayManualRecovery(bumpInfo); | ||
console.error(result.stderr); | ||
process.exit(1); | ||
return; | ||
} | ||
}); | ||
console.log('Reverting'); | ||
revertLocalChanges(cwd); | ||
} | ||
function bumpAndPush(publishBranch: string, options: CliOptions) { | ||
const { path: cwd, branch, tag, message } = options; | ||
const { remote, remoteBranch } = parseRemoteBranch(branch); | ||
console.log('Fetching from remote'); | ||
// pull in latest from origin branch | ||
gitFailFast(['fetch', remote], { cwd }); | ||
const mergeResult = git(['merge', '-X', 'theirs', `${branch}`], { cwd }); | ||
if (!mergeResult.success) { | ||
console.error(`CRITICAL ERROR: pull from ${branch} has failed!`); | ||
console.error(mergeResult.stderr); | ||
process.exit(1); | ||
} | ||
// bump the version | ||
console.log('Bumping the versions for git push'); | ||
const bumpInfo = bump(cwd); | ||
// checkin | ||
const mergePublishBranchResult = mergePublishBranch(publishBranch, branch, message, cwd); | ||
if (!mergePublishBranchResult.success) { | ||
console.error('CRITICAL ERROR: merging to target has failed!'); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
// Step 3. Tag & Push to remote | ||
tagPackages(bumpInfo, tag, cwd); | ||
console.log(`pushing to ${branch}, running the following command for git push:`); | ||
const pushArgs = ['push', '--no-verify', '--follow-tags', '--verbose', remote, `HEAD:${remoteBranch}`]; | ||
console.log('git ' + pushArgs.join(' ')); | ||
const pushResult = git(pushArgs, { cwd }); | ||
if (!pushResult.success) { | ||
console.error(`CRITICAL ERROR: push to ${branch} has failed!`); | ||
console.error(pushResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} else { | ||
console.log(pushResult.stdout.toString()); | ||
console.log(pushResult.stderr.toString()); | ||
} | ||
} | ||
export async function publish(options: CliOptions) { | ||
const { path: cwd, branch, registry, tag, token, message, access } = options; | ||
const { path: cwd, branch, registry, tag, message } = options; | ||
@@ -53,27 +128,5 @@ // First, validate that we have changes to publish | ||
// Step 1. Bump + npm publish | ||
// bump the version | ||
console.log('Bumping version for npm publish'); | ||
const bumpInfo = bump(cwd); | ||
if (!validatePackageVersions(bumpInfo, registry)) { | ||
displayManualRecovery(bumpInfo); | ||
console.error('No packages have been published'); | ||
process.exit(1); | ||
} | ||
// npm / yarn publish | ||
if (options.publish) { | ||
Object.keys(bumpInfo.packageChangeTypes).forEach(pkg => { | ||
const packageInfo = bumpInfo.packageInfos[pkg]; | ||
console.log(`Publishing - ${packageInfo.name}@${packageInfo.version}`); | ||
const result = packagePublish(packageInfo, registry, token, tag, access); | ||
if (result.success) { | ||
console.log('Published!'); | ||
} else { | ||
displayManualRecovery(bumpInfo); | ||
console.error(result.stderr); | ||
process.exit(1); | ||
return; | ||
} | ||
}); | ||
publishToRegistry(options); | ||
} else { | ||
@@ -85,45 +138,6 @@ console.log('Skipping publish'); | ||
// - reset, fetch latest from origin/master (to ensure less chance of conflict), then bump again + commit | ||
if (!branch || !options.push) { | ||
if (branch && options.push) { | ||
bumpAndPush(publishBranch, options); | ||
} else { | ||
console.log('Skipping git push and tagging'); | ||
} else { | ||
const { remote, remoteBranch } = parseRemoteBranch(branch); | ||
console.log('Reverting and fetching from remote'); | ||
// pull in latest from origin branch | ||
revertLocalChanges(cwd); | ||
gitFailFast(['fetch', remote], { cwd }); | ||
const mergeResult = git(['merge', '-X', 'theirs', `${branch}`], { cwd }); | ||
if (!mergeResult.success) { | ||
console.error(`CRITICAL ERROR: pull from ${branch} has failed!`); | ||
console.error(mergeResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
// bump the version | ||
console.log('Bumping the versions for git push'); | ||
bump(cwd); | ||
// checkin | ||
const mergePublishBranchResult = mergePublishBranch(publishBranch, branch, message, cwd); | ||
if (!mergePublishBranchResult.success) { | ||
console.error('CRITICAL ERROR: merging to target has failed!'); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
// Step 3. Tag & Push to remote | ||
tagPackages(bumpInfo, tag, cwd); | ||
console.log(`pushing to ${branch}, running the following command for git push:`); | ||
const pushArgs = ['push', '--no-verify', '--follow-tags', '--verbose', remote, `HEAD:${remoteBranch}`]; | ||
console.log('git ' + pushArgs.join(' ')); | ||
const pushResult = git(pushArgs); | ||
if (!pushResult.success) { | ||
console.error(`CRITICAL ERROR: push to ${branch} has failed!`); | ||
console.error(pushResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
} | ||
@@ -130,0 +144,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
177028
91
4285
11