beachball
Advanced tools
Comparing version 1.12.2 to 1.13.0
@@ -5,3 +5,17 @@ { | ||
{ | ||
"date": "Tue, 27 Aug 2019 17:44:26 GMT", | ||
"date": "Tue, 03 Sep 2019 19:59:34 GMT", | ||
"tag": "beachball_v1.13.0", | ||
"version": "1.13.0", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"comment": "allow staged files to be counted for changes as well", | ||
"author": "kchau@microsoft.com", | ||
"commit": "7c4f51cdf4131bbf415781dc8af98cc575a78f73" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 27 Aug 2019 17:44:33 GMT", | ||
"tag": "beachball_v1.12.2", | ||
@@ -8,0 +22,0 @@ "version": "1.12.2", |
# Change Log - beachball | ||
This log was last generated on Tue, 27 Aug 2019 17:44:26 GMT and should not be manually modified. | ||
This log was last generated on Tue, 03 Sep 2019 19:59:34 GMT and should not be manually modified. | ||
## 1.13.0 | ||
Tue, 03 Sep 2019 19:59:34 GMT | ||
### Minor changes | ||
- allow staged files to be counted for changes as well (kchau@microsoft.com) | ||
## 1.12.2 | ||
Tue, 27 Aug 2019 17:44:26 GMT | ||
Tue, 27 Aug 2019 17:44:33 GMT | ||
@@ -8,0 +14,0 @@ ### Patches |
@@ -32,4 +32,4 @@ "use strict"; | ||
yes: ['y'], | ||
package: ['p'] | ||
} | ||
package: ['p'], | ||
}, | ||
}); | ||
@@ -59,3 +59,3 @@ if (args.help) { | ||
type: args.type || null, | ||
fetch: args.fetch !== false | ||
fetch: args.fetch !== false, | ||
}; | ||
@@ -68,7 +68,7 @@ (() => __awaiter(this, void 0, void 0, function* () { | ||
} | ||
const uncommitted = git_1.getUncommittedChanges(options.path); | ||
if (uncommitted && uncommitted.length > 0) { | ||
console.error('ERROR: There are uncommitted changes in your repository. Please commit these files first:'); | ||
console.error('- ' + uncommitted.join('\n- ')); | ||
process.exit(1); | ||
const untracked = git_1.getUntrackedChanges(options.path); | ||
if (untracked && untracked.length > 0) { | ||
console.warn('WARN: There are untracked changes in your repository:'); | ||
console.warn('- ' + untracked.join('\n- ')); | ||
console.warn('Changes in these files will not trigger a prompt for change descriptions'); | ||
} | ||
@@ -75,0 +75,0 @@ const isChangeNeeded = validation_1.isChangeFileNeeded(options.branch, options.path, options.fetch); |
@@ -15,3 +15,3 @@ "use strict"; | ||
function getAllChangedPackages(branch, cwd) { | ||
const changes = git_1.getChanges(branch, cwd); | ||
const changes = [...(git_1.getChanges(branch, cwd) || []), ...(git_1.getStagedChanges(branch, cwd) || [])]; | ||
const ignoredFiles = ['CHANGELOG.md', 'CHANGELOG.json']; | ||
@@ -18,0 +18,0 @@ const packageRoots = {}; |
@@ -21,5 +21,6 @@ /** | ||
}): void; | ||
export declare function getUncommittedChanges(cwd: string): string[] | undefined; | ||
export declare function getUntrackedChanges(cwd: string): string[] | undefined; | ||
export declare function fetchAll(cwd: string): void; | ||
export declare function getChanges(branch: string, cwd: string): string[] | undefined; | ||
export declare function getStagedChanges(branch: string, cwd: string): string[] | undefined; | ||
export declare function getRecentCommitMessages(branch: string, cwd: string): string[] | undefined; | ||
@@ -26,0 +27,0 @@ export declare function getUserEmail(cwd: string): string | null | undefined; |
@@ -20,5 +20,5 @@ "use strict"; | ||
return { | ||
stderr: results.stderr.toString().trim(), | ||
stdout: results.stdout.toString().trim(), | ||
success: true | ||
stderr: results.stderr.toString().trimRight(), | ||
stdout: results.stdout.toString().trimRight(), | ||
success: true, | ||
}; | ||
@@ -28,5 +28,5 @@ } | ||
return { | ||
stderr: results.stderr.toString().trim(), | ||
stdout: results.stdout.toString().trim(), | ||
success: false | ||
stderr: results.stderr.toString().trimRight(), | ||
stdout: results.stdout.toString().trimRight(), | ||
success: false, | ||
}; | ||
@@ -45,4 +45,4 @@ } | ||
console.error(`CRITICAL ERROR: running git command: git ${args.join(' ')}!`); | ||
console.error(gitResult.stdout && gitResult.stdout.toString().trim()); | ||
console.error(gitResult.stderr && gitResult.stderr.toString().trim()); | ||
console.error(gitResult.stdout && gitResult.stdout.toString().trimRight()); | ||
console.error(gitResult.stderr && gitResult.stderr.toString().trimRight()); | ||
process.exit(1); | ||
@@ -52,5 +52,5 @@ } | ||
exports.gitFailFast = gitFailFast; | ||
function getUncommittedChanges(cwd) { | ||
function getUntrackedChanges(cwd) { | ||
try { | ||
const results = git(['status', '--porcelain'], { cwd }); | ||
const results = git(['status', '-z'], { cwd }); | ||
if (!results.success) { | ||
@@ -63,4 +63,14 @@ return []; | ||
} | ||
const lines = changes.split(/\n/) || []; | ||
return lines.map(line => line.trim().split(/\s+/)[1]); | ||
const lines = changes.split(/\0/).filter(line => line) || []; | ||
const untracked = []; | ||
for (let i = 0; i < lines.length; i++) { | ||
const line = lines[i]; | ||
if (line[0] === ' ' || line[0] === '?') { | ||
untracked.push(line.substr(3)); | ||
} | ||
else if (line[0] === 'R') { | ||
i++; | ||
} | ||
} | ||
return untracked; | ||
} | ||
@@ -71,3 +81,3 @@ catch (e) { | ||
} | ||
exports.getUncommittedChanges = getUncommittedChanges; | ||
exports.getUntrackedChanges = getUntrackedChanges; | ||
function fetchAll(cwd) { | ||
@@ -99,2 +109,20 @@ const results = git(['fetch', '-a'], { cwd }); | ||
exports.getChanges = getChanges; | ||
function getStagedChanges(branch, cwd) { | ||
try { | ||
const results = git(['--no-pager', 'diff', '--staged', '--name-only'], { cwd }); | ||
if (!results.success) { | ||
return []; | ||
} | ||
let changes = results.stdout; | ||
let lines = changes.split(/\n/) || []; | ||
return lines | ||
.filter(line => line.trim() !== '') | ||
.map(line => line.trim()) | ||
.filter(line => !line.includes('node_modules')); | ||
} | ||
catch (e) { | ||
console.error('Cannot gather information about changes: ', e.message); | ||
} | ||
} | ||
exports.getStagedChanges = getStagedChanges; | ||
function getRecentCommitMessages(branch, cwd) { | ||
@@ -240,3 +268,3 @@ try { | ||
remote, | ||
remoteBranch | ||
remoteBranch, | ||
}; | ||
@@ -243,0 +271,0 @@ } |
{ | ||
"name": "beachball", | ||
"version": "1.12.2", | ||
"version": "1.13.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
import { bump } from './bump'; | ||
import { CliOptions } from './CliOptions'; | ||
import { findGitRoot } from './paths'; | ||
import { getUncommittedChanges, getDefaultRemoteBranch } from './git'; | ||
import { isChangeFileNeeded as checkChangeFileNeeded, isGitAvailable, isValidPackageName, isValidChangeType } from './validation'; | ||
import { getUntrackedChanges, getDefaultRemoteBranch } from './git'; | ||
import { | ||
isChangeFileNeeded as checkChangeFileNeeded, | ||
isGitAvailable, | ||
isValidPackageName, | ||
isValidChangeType, | ||
} from './validation'; | ||
import { promptForChange, writeChangeFiles } from './changefile'; | ||
@@ -21,4 +26,4 @@ import { publish } from './publish'; | ||
yes: ['y'], | ||
package: ['p'] | ||
} | ||
package: ['p'], | ||
}, | ||
}); | ||
@@ -52,3 +57,3 @@ | ||
type: args.type || null, | ||
fetch: args.fetch !== false | ||
fetch: args.fetch !== false, | ||
}; | ||
@@ -64,8 +69,8 @@ | ||
const uncommitted = getUncommittedChanges(options.path); | ||
const untracked = getUntrackedChanges(options.path); | ||
if (uncommitted && uncommitted.length > 0) { | ||
console.error('ERROR: There are uncommitted changes in your repository. Please commit these files first:'); | ||
console.error('- ' + uncommitted.join('\n- ')); | ||
process.exit(1); | ||
if (untracked && untracked.length > 0) { | ||
console.warn('WARN: There are untracked changes in your repository:'); | ||
console.warn('- ' + untracked.join('\n- ')); | ||
console.warn('Changes in these files will not trigger a prompt for change descriptions'); | ||
} | ||
@@ -72,0 +77,0 @@ |
import { ChangeInfo } from './ChangeInfo'; | ||
import { findPackageRoot, getChangePath } from './paths'; | ||
import { getChanges, git, fetchAll } from './git'; | ||
import { getChanges, getStagedChanges, git, fetchAll } from './git'; | ||
import fs from 'fs'; | ||
@@ -12,3 +12,3 @@ import path from 'path'; | ||
function getAllChangedPackages(branch: string, cwd: string) { | ||
const changes = getChanges(branch, cwd); | ||
const changes = [...(getChanges(branch, cwd) || []), ...(getStagedChanges(branch, cwd) || [])]; | ||
const ignoredFiles = ['CHANGELOG.md', 'CHANGELOG.json']; | ||
@@ -15,0 +15,0 @@ const packageRoots: { [pathName: string]: string } = {}; |
@@ -17,11 +17,11 @@ import { spawnSync } from 'child_process'; | ||
return { | ||
stderr: results.stderr.toString().trim(), | ||
stdout: results.stdout.toString().trim(), | ||
success: true | ||
stderr: results.stderr.toString().trimRight(), | ||
stdout: results.stdout.toString().trimRight(), | ||
success: true, | ||
}; | ||
} else { | ||
return { | ||
stderr: results.stderr.toString().trim(), | ||
stdout: results.stdout.toString().trim(), | ||
success: false | ||
stderr: results.stderr.toString().trimRight(), | ||
stdout: results.stdout.toString().trimRight(), | ||
success: false, | ||
}; | ||
@@ -40,4 +40,4 @@ } | ||
console.error(`CRITICAL ERROR: running git command: git ${args.join(' ')}!`); | ||
console.error(gitResult.stdout && gitResult.stdout.toString().trim()); | ||
console.error(gitResult.stderr && gitResult.stderr.toString().trim()); | ||
console.error(gitResult.stdout && gitResult.stdout.toString().trimRight()); | ||
console.error(gitResult.stderr && gitResult.stderr.toString().trimRight()); | ||
process.exit(1); | ||
@@ -47,5 +47,5 @@ } | ||
export function getUncommittedChanges(cwd: string) { | ||
export function getUntrackedChanges(cwd: string) { | ||
try { | ||
const results = git(['status', '--porcelain'], { cwd }); | ||
const results = git(['status', '-z'], { cwd }); | ||
@@ -62,5 +62,16 @@ if (!results.success) { | ||
const lines = changes.split(/\n/) || []; | ||
const lines = changes.split(/\0/).filter(line => line) || []; | ||
return lines.map(line => line.trim().split(/\s+/)[1]); | ||
const untracked: string[] = []; | ||
for (let i = 0; i < lines.length; i++) { | ||
const line = lines[i]; | ||
if (line[0] === ' ' || line[0] === '?') { | ||
untracked.push(line.substr(3)); | ||
} else if (line[0] === 'R') { | ||
i++; | ||
} | ||
} | ||
return untracked; | ||
} catch (e) { | ||
@@ -100,2 +111,23 @@ console.error('Cannot gather information about changes: ', e.message); | ||
export function getStagedChanges(branch: string, cwd: string) { | ||
try { | ||
const results = git(['--no-pager', 'diff', '--staged', '--name-only'], { cwd }); | ||
if (!results.success) { | ||
return []; | ||
} | ||
let changes = results.stdout; | ||
let lines = changes.split(/\n/) || []; | ||
return lines | ||
.filter(line => line.trim() !== '') | ||
.map(line => line.trim()) | ||
.filter(line => !line.includes('node_modules')); | ||
} catch (e) { | ||
console.error('Cannot gather information about changes: ', e.message); | ||
} | ||
} | ||
export function getRecentCommitMessages(branch: string, cwd: string) { | ||
@@ -227,3 +259,5 @@ try { | ||
const showBranchLines = showBranchResult.stdout.split(/\n/); | ||
const parentLine = showBranchLines.find(line => line.indexOf('*') > -1 && line.indexOf(branchName) < 0 && line.indexOf('publish_') < 0); | ||
const parentLine = showBranchLines.find( | ||
line => line.indexOf('*') > -1 && line.indexOf(branchName) < 0 && line.indexOf('publish_') < 0 | ||
); | ||
@@ -263,3 +297,3 @@ if (!parentLine) { | ||
remote, | ||
remoteBranch | ||
remoteBranch, | ||
}; | ||
@@ -266,0 +300,0 @@ } |
Sorry, the diff of this file is not supported yet
145002
3533