beachball
Advanced tools
Comparing version 1.14.1 to 1.14.2
@@ -5,3 +5,17 @@ { | ||
{ | ||
"date": "Fri, 04 Oct 2019 15:11:35 GMT", | ||
"date": "Wed, 23 Oct 2019 17:31:59 GMT", | ||
"tag": "beachball_v1.14.2", | ||
"version": "1.14.2", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "make sure that we don't have file names in change files", | ||
"author": "kchau@microsoft.com", | ||
"commit": "ff943956e212d97df0e781a50b8cfce189108a51" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Fri, 04 Oct 2019 15:11:40 GMT", | ||
"tag": "beachball_v1.14.1", | ||
@@ -8,0 +22,0 @@ "version": "1.14.1", |
# Change Log - beachball | ||
This log was last generated on Fri, 04 Oct 2019 15:11:35 GMT and should not be manually modified. | ||
This log was last generated on Wed, 23 Oct 2019 17:31:59 GMT and should not be manually modified. | ||
## 1.14.2 | ||
Wed, 23 Oct 2019 17:31:59 GMT | ||
### Patches | ||
- make sure that we don't have file names in change files (kchau@microsoft.com) | ||
## 1.14.1 | ||
Fri, 04 Oct 2019 15:11:35 GMT | ||
Fri, 04 Oct 2019 15:11:40 GMT | ||
@@ -8,0 +14,0 @@ ### Patches |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -32,13 +24,13 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
let repositoryFactory; | ||
beforeAll(() => __awaiter(this, void 0, void 0, function* () { | ||
beforeAll(async () => { | ||
repositoryFactory = new repository_1.RepositoryFactory(); | ||
yield repositoryFactory.create(); | ||
})); | ||
await repositoryFactory.create(); | ||
}); | ||
describe('writeChangelog', () => { | ||
let repository; | ||
beforeEach(() => __awaiter(this, void 0, void 0, function* () { | ||
repository = yield repositoryFactory.cloneRepository(); | ||
})); | ||
it('generate changelog is a valid markdown file', () => __awaiter(this, void 0, void 0, function* () { | ||
yield repository.commitChange('foo'); | ||
beforeEach(async () => { | ||
repository = await repositoryFactory.cloneRepository(); | ||
}); | ||
it('generate changelog is a valid markdown file', async () => { | ||
await repository.commitChange('foo'); | ||
changefile_1.writeChangeFiles({ | ||
@@ -54,3 +46,3 @@ foo: { | ||
}, repository.rootPath); | ||
yield repository.commitChange('bar'); | ||
await repository.commitChange('bar'); | ||
changefile_1.writeChangeFiles({ | ||
@@ -71,3 +63,3 @@ foo: { | ||
const changelogFile = path_1.default.join(repository.rootPath, 'CHANGELOG.md'); | ||
const text = yield readFileAsync(changelogFile, 'utf-8'); | ||
const text = await readFileAsync(changelogFile, 'utf-8'); | ||
const tree = parseMarkdown(text); | ||
@@ -77,4 +69,4 @@ const listItems = unist_util_select_1.selectAll('listItem paragraph text', tree); | ||
expect(listItems.find(item => item.value === 'comment 1 (test@testtestme.com)')).toBeTruthy(); | ||
})); | ||
}); | ||
}); | ||
}); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,5 +16,5 @@ const registry_1 = require("../fixtures/registry"); | ||
describe('packagePublish', () => { | ||
beforeEach(() => __awaiter(this, void 0, void 0, function* () { | ||
yield registry.reset(); | ||
})); | ||
beforeEach(async () => { | ||
await registry.reset(); | ||
}); | ||
it('can publish', () => { | ||
@@ -57,3 +49,3 @@ const publishResult = packageManager_1.packagePublish(package_1.testPackageInfo, registry.getUrl(), '', package_1.testTag, ''); | ||
it('publish package with defaultNpmTag publishes as defaultNpmTag', () => { | ||
const testPackageInfoWithDefaultNpmTag = Object.assign({}, package_1.testPackageInfo, { defaultNpmTag: package_1.testTag }); | ||
const testPackageInfoWithDefaultNpmTag = { ...package_1.testPackageInfo, defaultNpmTag: package_1.testTag }; | ||
const publishResult = packageManager_1.packagePublish(testPackageInfoWithDefaultNpmTag, registry.getUrl(), '', undefined, ''); | ||
@@ -76,3 +68,3 @@ expect(publishResult.success).toBeTruthy(); | ||
it('publish with specified tag overrides defaultNpmTag', () => { | ||
const testPackageInfoWithDefaultNpmTag = Object.assign({}, package_1.testPackageInfo, { defaultNpmTag: 'thisShouldNotBeUsed' }); | ||
const testPackageInfoWithDefaultNpmTag = { ...package_1.testPackageInfo, defaultNpmTag: 'thisShouldNotBeUsed' }; | ||
const publishResult = packageManager_1.packagePublish(testPackageInfoWithDefaultNpmTag, registry.getUrl(), '', package_1.testTag, ''); | ||
@@ -79,0 +71,0 @@ expect(publishResult.success).toBeTruthy(); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -23,8 +15,8 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
let repositoryFactory; | ||
beforeEach(() => __awaiter(this, void 0, void 0, function* () { | ||
beforeEach(async () => { | ||
repositoryFactory = new repository_1.RepositoryFactory(); | ||
yield repositoryFactory.create(); | ||
})); | ||
it('can perform a successful git push', () => __awaiter(this, void 0, void 0, function* () { | ||
const repo = yield repositoryFactory.cloneRepository(); | ||
await repositoryFactory.create(); | ||
}); | ||
it('can perform a successful git push', async () => { | ||
const repo = await repositoryFactory.cloneRepository(); | ||
changefile_1.writeChangeFiles({ | ||
@@ -41,3 +33,3 @@ foo: { | ||
git_1.git(['push', 'origin', 'master'], { cwd: repo.rootPath }); | ||
yield publish_1.publish({ | ||
await publish_1.publish({ | ||
branch: 'origin/master', | ||
@@ -59,9 +51,9 @@ command: 'publish', | ||
}); | ||
const newRepo = yield repositoryFactory.cloneRepository(); | ||
const newRepo = await repositoryFactory.cloneRepository(); | ||
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(newRepo.rootPath, 'package.json'), 'utf-8')); | ||
expect(packageJson.version).toBe('1.1.0'); | ||
})); | ||
it('can handle a merge when there are change files present', () => __awaiter(this, void 0, void 0, function* () { | ||
}); | ||
it('can handle a merge when there are change files present', async () => { | ||
// 1. clone a new repo1, write a change file in repo1 | ||
const repo1 = yield repositoryFactory.cloneRepository(); | ||
const repo1 = await repositoryFactory.cloneRepository(); | ||
changefile_1.writeChangeFiles({ | ||
@@ -101,3 +93,3 @@ foo: { | ||
// 3. Meanwhile, in repo2, also create a new change file | ||
const repo2 = yield repositoryFactory.cloneRepository(); | ||
const repo2 = await repositoryFactory.cloneRepository(); | ||
changefile_1.writeChangeFiles({ | ||
@@ -115,5 +107,5 @@ foo2: { | ||
// 4. Pretend to continue on with repo1's publish | ||
yield publish_1.bumpAndPush(bumpInfo, publishBranch, options); | ||
await publish_1.bumpAndPush(bumpInfo, publishBranch, options); | ||
// 5. In a brand new cloned repo, make assertions | ||
const newRepo = yield repositoryFactory.cloneRepository(); | ||
const newRepo = await repositoryFactory.cloneRepository(); | ||
const newChangePath = path_1.default.join(newRepo.rootPath, 'change'); | ||
@@ -125,3 +117,3 @@ expect(fs_1.default.existsSync(newChangePath)).toBeTruthy(); | ||
expect(changeFileContent.packageName).toBe('foo2'); | ||
})); | ||
}); | ||
}); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -27,9 +19,9 @@ const registry_1 = require("../fixtures/registry"); | ||
describe('publishToRegistry', () => { | ||
beforeEach(() => __awaiter(this, void 0, void 0, function* () { | ||
yield registry.reset(); | ||
})); | ||
it('can perform a successful npm publish', () => __awaiter(this, void 0, void 0, function* () { | ||
beforeEach(async () => { | ||
await registry.reset(); | ||
}); | ||
it('can perform a successful npm publish', async () => { | ||
const repositoryFactory = new repository_1.RepositoryFactory(); | ||
yield repositoryFactory.create(); | ||
const repo = yield repositoryFactory.cloneRepository(); | ||
await repositoryFactory.create(); | ||
const repo = await repositoryFactory.cloneRepository(); | ||
changefile_1.writeChangeFiles({ | ||
@@ -46,3 +38,3 @@ foo: { | ||
git_1.git(['push', 'origin', 'master'], { cwd: repo.rootPath }); | ||
yield publish_1.publish({ | ||
await publish_1.publish({ | ||
branch: 'origin/master', | ||
@@ -69,8 +61,8 @@ command: 'publish', | ||
expect(show.versions.length).toEqual(1); | ||
})); | ||
it('can perform a successful npm publish even with private packages', () => __awaiter(this, void 0, void 0, function* () { | ||
}); | ||
it('can perform a successful npm publish even with private packages', async () => { | ||
const repositoryFactory = new repository_1.RepositoryFactory(); | ||
yield repositoryFactory.create(); | ||
const repo = yield repositoryFactory.cloneRepository(); | ||
yield repo.commitChange('packages/foopkg/package.json', JSON.stringify({ | ||
await repositoryFactory.create(); | ||
const repo = await repositoryFactory.cloneRepository(); | ||
await repo.commitChange('packages/foopkg/package.json', JSON.stringify({ | ||
name: 'foopkg', | ||
@@ -80,7 +72,7 @@ version: '1.0.0', | ||
})); | ||
yield repo.commitChange('packages/publicpkg/package.json', JSON.stringify({ | ||
await repo.commitChange('packages/publicpkg/package.json', JSON.stringify({ | ||
name: 'publicpkg', | ||
version: '1.0.0', | ||
})); | ||
yield repo.commitChange('package.json', JSON.stringify({ | ||
await repo.commitChange('package.json', JSON.stringify({ | ||
name: 'foo-repo', | ||
@@ -101,3 +93,3 @@ version: '1.0.0', | ||
git_1.git(['push', 'origin', 'master'], { cwd: repo.rootPath }); | ||
yield publish_1.publish({ | ||
await publish_1.publish({ | ||
branch: 'origin/master', | ||
@@ -121,16 +113,16 @@ command: 'publish', | ||
expect(showResult.success).toBeFalsy(); | ||
})); | ||
fit('can perform a successful npm publish even with a non-existent package listed in the change file', () => __awaiter(this, void 0, void 0, function* () { | ||
}); | ||
fit('can perform a successful npm publish even with a non-existent package listed in the change file', async () => { | ||
const repositoryFactory = new repository_1.RepositoryFactory(); | ||
yield repositoryFactory.create(); | ||
const repo = yield repositoryFactory.cloneRepository(); | ||
yield repo.commitChange('packages/foopkg/package.json', JSON.stringify({ | ||
await repositoryFactory.create(); | ||
const repo = await repositoryFactory.cloneRepository(); | ||
await repo.commitChange('packages/foopkg/package.json', JSON.stringify({ | ||
name: 'foopkg', | ||
version: '1.0.0', | ||
})); | ||
yield repo.commitChange('packages/publicpkg/package.json', JSON.stringify({ | ||
await repo.commitChange('packages/publicpkg/package.json', JSON.stringify({ | ||
name: 'publicpkg', | ||
version: '1.0.0', | ||
})); | ||
yield repo.commitChange('package.json', JSON.stringify({ | ||
await repo.commitChange('package.json', JSON.stringify({ | ||
name: 'foo-repo', | ||
@@ -151,3 +143,3 @@ version: '1.0.0', | ||
git_1.git(['push', 'origin', 'master'], { cwd: repo.rootPath }); | ||
yield publish_1.publish({ | ||
await publish_1.publish({ | ||
branch: 'origin/master', | ||
@@ -171,4 +163,4 @@ command: 'publish', | ||
expect(showResult.success).toBeFalsy(); | ||
})); | ||
}); | ||
}); | ||
}); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -15,28 +7,28 @@ const repository_1 = require("../fixtures/repository"); | ||
let repositoryFactory; | ||
beforeAll(() => __awaiter(this, void 0, void 0, function* () { | ||
beforeAll(async () => { | ||
repositoryFactory = new repository_1.RepositoryFactory(); | ||
yield repositoryFactory.create(); | ||
})); | ||
await repositoryFactory.create(); | ||
}); | ||
describe('isChangeFileNeeded', () => { | ||
let repository; | ||
beforeEach(() => __awaiter(this, void 0, void 0, function* () { | ||
repository = yield repositoryFactory.cloneRepository(); | ||
})); | ||
it('is false when no changes have been made', () => __awaiter(this, void 0, void 0, function* () { | ||
beforeEach(async () => { | ||
repository = await repositoryFactory.cloneRepository(); | ||
}); | ||
it('is false when no changes have been made', async () => { | ||
const result = validation_1.isChangeFileNeeded('origin/master', repository.rootPath, false); | ||
expect(result).toBeFalsy(); | ||
})); | ||
it('is true when changes exist in a new branch', () => __awaiter(this, void 0, void 0, function* () { | ||
yield repository.branch('feature-0'); | ||
yield repository.commitChange('myFilename'); | ||
}); | ||
it('is true when changes exist in a new branch', async () => { | ||
await repository.branch('feature-0'); | ||
await repository.commitChange('myFilename'); | ||
const result = validation_1.isChangeFileNeeded('origin/master', repository.rootPath, false); | ||
expect(result).toBeTruthy(); | ||
})); | ||
it('is false when changes are CHANGELOG files', () => __awaiter(this, void 0, void 0, function* () { | ||
yield repository.branch('feature-0'); | ||
yield repository.commitChange('CHANGELOG.md'); | ||
}); | ||
it('is false when changes are CHANGELOG files', async () => { | ||
await repository.branch('feature-0'); | ||
await repository.commitChange('CHANGELOG.md'); | ||
const result = validation_1.isChangeFileNeeded('origin/master', repository.rootPath, false); | ||
expect(result).toBeFalsy(); | ||
})); | ||
}); | ||
}); | ||
}); |
import { getPackageChangeTypes } from './changefile'; | ||
import { getPackageInfos } from './monorepo'; | ||
import { ChangeInfo } from './ChangeInfo'; | ||
import { ChangeSet } from './ChangeInfo'; | ||
export { PackageInfo } from './PackageInfo'; | ||
@@ -13,10 +13,10 @@ export declare type BumpInfo = ReturnType<typeof bump>; | ||
}; | ||
changes: ChangeInfo[]; | ||
changes: Map<string, import("./ChangeInfo").ChangeInfo>; | ||
}; | ||
export declare function performBump(bumpInfo: { | ||
changes: ChangeInfo[]; | ||
changes: ChangeSet; | ||
packageInfos: ReturnType<typeof getPackageInfos>; | ||
packageChangeTypes: ReturnType<typeof getPackageChangeTypes>; | ||
}, cwd: string): { | ||
changes: ChangeInfo[]; | ||
changes: Map<string, import("./ChangeInfo").ChangeInfo>; | ||
packageChangeTypes: { | ||
@@ -30,3 +30,3 @@ [pkgName: string]: import("./ChangeInfo").ChangeType; | ||
export declare function bump(cwd: string): { | ||
changes: ChangeInfo[]; | ||
changes: Map<string, import("./ChangeInfo").ChangeInfo>; | ||
packageChangeTypes: { | ||
@@ -33,0 +33,0 @@ [pkgName: string]: import("./ChangeInfo").ChangeType; |
@@ -17,5 +17,8 @@ "use strict"; | ||
// Clear non-existent changes | ||
const filteredChanges = changes.filter(change => { | ||
return packageInfos[change.packageName]; | ||
}); | ||
const filteredChanges = new Map(); | ||
for (let [changeFile, change] of changes) { | ||
if (packageInfos[change.packageName]) { | ||
filteredChanges.set(changeFile, change); | ||
} | ||
} | ||
// Clear non-existent changeTypes | ||
@@ -22,0 +25,0 @@ Object.keys(packageChangeTypes).forEach(packageName => { |
@@ -1,2 +0,2 @@ | ||
import { ChangeInfo, ChangeType } from './ChangeInfo'; | ||
import { ChangeInfo, ChangeType, ChangeSet } from './ChangeInfo'; | ||
import { CliOptions } from './CliOptions'; | ||
@@ -25,9 +25,9 @@ import { PackageInfo } from './PackageInfo'; | ||
*/ | ||
export declare function unlinkChangeFiles(changes: ChangeInfo[], packageInfos: { | ||
export declare function unlinkChangeFiles(changeSet: ChangeSet, packageInfos: { | ||
[pkg: string]: PackageInfo; | ||
}, cwd: string): void; | ||
export declare function readChangeFiles(cwd: string): ChangeInfo[]; | ||
export declare function getPackageChangeTypes(changes: ChangeInfo[]): { | ||
export declare function readChangeFiles(cwd: string): Map<string, ChangeInfo>; | ||
export declare function getPackageChangeTypes(changeSet: ChangeSet): { | ||
[pkgName: string]: ChangeType; | ||
}; | ||
//# sourceMappingURL=changefile.d.ts.map |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -26,61 +18,65 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
function promptForChange(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { branch, path: cwd, package: specificPackage, fetch } = options; | ||
const changedPackages = specificPackage ? [specificPackage] : getChangedPackages_1.getChangedPackages(branch, cwd, fetch); | ||
const recentMessages = git_1.getRecentCommitMessages(branch, cwd) || []; | ||
const packageChangeInfo = {}; | ||
const packageInfos = monorepo_1.getPackageInfos(cwd); | ||
for (let pkg of changedPackages) { | ||
console.log(''); | ||
console.log(`Please describe the changes for: ${pkg}`); | ||
const showPrereleaseOption = semver_1.prerelease(packageInfos[pkg].version); | ||
const changeTypePrompt = { | ||
type: 'select', | ||
name: 'type', | ||
message: 'Change type', | ||
choices: [ | ||
...(showPrereleaseOption ? [{ value: 'prerelease', title: ' [1mPrerelease[22m - bump prerelease version' }] : []), | ||
{ value: 'patch', title: ' [1mPatch[22m - bug fixes; no backwards incompatible changes.' }, | ||
{ value: 'minor', title: ' [1mMinor[22m - small feature; backwards compatible changes.' }, | ||
{ value: 'none', title: ' [1mNone[22m - this change does not affect the published package in any way.' }, | ||
{ value: 'major', title: ' [1mMajor[22m - major feature; breaking changes.' }, | ||
].filter(choice => !packageInfos[pkg].disallowedChangeTypes.includes(choice.value)), | ||
}; | ||
if (changeTypePrompt.choices.length === 0) { | ||
console.log('No valid changeTypes available, aborting'); | ||
async function promptForChange(options) { | ||
const { branch, path: cwd, package: specificPackage, fetch } = options; | ||
const changedPackages = specificPackage ? [specificPackage] : getChangedPackages_1.getChangedPackages(branch, cwd, fetch); | ||
const recentMessages = git_1.getRecentCommitMessages(branch, cwd) || []; | ||
const packageChangeInfo = {}; | ||
const packageInfos = monorepo_1.getPackageInfos(cwd); | ||
for (let pkg of changedPackages) { | ||
console.log(''); | ||
console.log(`Please describe the changes for: ${pkg}`); | ||
const showPrereleaseOption = semver_1.prerelease(packageInfos[pkg].version); | ||
const changeTypePrompt = { | ||
type: 'select', | ||
name: 'type', | ||
message: 'Change type', | ||
choices: [ | ||
...(showPrereleaseOption ? [{ value: 'prerelease', title: ' [1mPrerelease[22m - bump prerelease version' }] : []), | ||
{ value: 'patch', title: ' [1mPatch[22m - bug fixes; no backwards incompatible changes.' }, | ||
{ value: 'minor', title: ' [1mMinor[22m - small feature; backwards compatible changes.' }, | ||
{ value: 'none', title: ' [1mNone[22m - this change does not affect the published package in any way.' }, | ||
{ value: 'major', title: ' [1mMajor[22m - major feature; breaking changes.' }, | ||
].filter(choice => !packageInfos[pkg].disallowedChangeTypes.includes(choice.value)), | ||
}; | ||
if (changeTypePrompt.choices.length === 0) { | ||
console.log('No valid changeTypes available, aborting'); | ||
return; | ||
} | ||
if (options.type && packageInfos[pkg].disallowedChangeTypes.includes(options.type)) { | ||
console.log(`${options.type} type is not allowed, aborting`); | ||
return; | ||
} | ||
const descriptionPrompt = { | ||
type: 'autocomplete', | ||
name: 'comment', | ||
message: 'Describe changes (type or choose one)', | ||
suggest: input => { | ||
return Promise.resolve([...recentMessages.filter(msg => msg.startsWith(input)), input]); | ||
}, | ||
}; | ||
const showChangeTypePrompt = !options.type && changeTypePrompt.choices.length > 1; | ||
const questions = [ | ||
...(showChangeTypePrompt ? [changeTypePrompt] : []), | ||
...(!options.message ? [descriptionPrompt] : []), | ||
]; | ||
let response = { | ||
type: options.type || 'none', | ||
comment: options.message || '', | ||
}; | ||
if (questions.length > 0) { | ||
response = (await prompts_1.default(questions)); | ||
if (Object.keys(response).length === 0) { | ||
console.log('Cancelled, no change files are written'); | ||
return; | ||
} | ||
if (options.type && packageInfos[pkg].disallowedChangeTypes.includes(options.type)) { | ||
console.log(`${options.type} type is not allowed, aborting`); | ||
return; | ||
} | ||
const descriptionPrompt = { | ||
type: 'autocomplete', | ||
name: 'comment', | ||
message: 'Describe changes (type or choose one)', | ||
suggest: input => { | ||
return Promise.resolve([...recentMessages.filter(msg => msg.startsWith(input)), input]); | ||
}, | ||
}; | ||
const showChangeTypePrompt = !options.type && changeTypePrompt.choices.length > 1; | ||
const questions = [ | ||
...(showChangeTypePrompt ? [changeTypePrompt] : []), | ||
...(!options.message ? [descriptionPrompt] : []), | ||
]; | ||
let response = { | ||
type: options.type || 'none', | ||
comment: options.message || '', | ||
}; | ||
if (questions.length > 0) { | ||
response = (yield prompts_1.default(questions)); | ||
if (Object.keys(response).length === 0) { | ||
console.log('Cancelled, no change files are written'); | ||
return; | ||
} | ||
} | ||
packageChangeInfo[pkg] = Object.assign({}, response, { packageName: pkg, email: git_1.getUserEmail(cwd) || 'email not defined', commit: git_1.getCurrentHash(cwd) || 'hash not available', date: new Date() }); | ||
} | ||
return packageChangeInfo; | ||
}); | ||
packageChangeInfo[pkg] = { | ||
...response, | ||
packageName: pkg, | ||
email: git_1.getUserEmail(cwd) || 'email not defined', | ||
commit: git_1.getCurrentHash(cwd) || 'hash not available', | ||
date: new Date(), | ||
}; | ||
} | ||
return packageChangeInfo; | ||
} | ||
@@ -116,3 +112,2 @@ exports.promptForChange = promptForChange; | ||
const change = changes[pkgName]; | ||
change.file = changeFile; | ||
fs_extra_1.default.writeFileSync(changeFile, JSON.stringify(change, null, 2)); | ||
@@ -134,12 +129,12 @@ changeFiles.push(changeFile); | ||
*/ | ||
function unlinkChangeFiles(changes, packageInfos, cwd) { | ||
function unlinkChangeFiles(changeSet, packageInfos, cwd) { | ||
const changePath = paths_1.getChangePath(cwd); | ||
if (!changePath || !changes) { | ||
if (!changePath || !changeSet) { | ||
return; | ||
} | ||
console.log('Removing change files:'); | ||
for (const change of changes) { | ||
if (change.file && packageInfos[change.packageName] && !packageInfos[change.packageName].private) { | ||
console.log(`- ${change.file}`); | ||
fs_extra_1.default.removeSync(path_1.default.join(changePath, change.file)); | ||
for (let [changeFile, change] of changeSet) { | ||
if (changeFile && packageInfos[change.packageName] && !packageInfos[change.packageName].private) { | ||
console.log(`- ${changeFile}`); | ||
fs_extra_1.default.removeSync(path_1.default.join(changePath, changeFile)); | ||
} | ||
@@ -168,12 +163,12 @@ } | ||
function readChangeFiles(cwd) { | ||
const changeSet = new Map(); | ||
const changePath = paths_1.getChangePath(cwd); | ||
if (!changePath || !fs_extra_1.default.existsSync(changePath)) { | ||
return []; | ||
return changeSet; | ||
} | ||
const changeFiles = fs_extra_1.default.readdirSync(changePath); | ||
const changes = []; | ||
changeFiles.forEach(changeFile => { | ||
try { | ||
const packageJson = JSON.parse(fs_extra_1.default.readFileSync(path_1.default.join(changePath, changeFile)).toString()); | ||
changes.push(Object.assign({}, packageJson, { file: changeFile })); | ||
changeSet.set(changeFile, packageJson); | ||
} | ||
@@ -184,6 +179,6 @@ catch (e) { | ||
}); | ||
return changes; | ||
return changeSet; | ||
} | ||
exports.readChangeFiles = readChangeFiles; | ||
function getPackageChangeTypes(changes) { | ||
function getPackageChangeTypes(changeSet) { | ||
const changeTypeWeights = { | ||
@@ -197,6 +192,6 @@ major: 4, | ||
const changePerPackage = {}; | ||
changes.forEach(change => { | ||
for (let [_, change] of changeSet) { | ||
const { packageName } = change; | ||
if (change.type === 'none') { | ||
return; | ||
continue; | ||
} | ||
@@ -207,5 +202,5 @@ if (!changePerPackage[packageName] || | ||
} | ||
}); | ||
} | ||
return changePerPackage; | ||
} | ||
exports.getPackageChangeTypes = getPackageChangeTypes; |
@@ -9,4 +9,4 @@ export declare type ChangeType = 'prerelease' | 'patch' | 'minor' | 'major' | 'none'; | ||
date: Date; | ||
file?: string; | ||
} | ||
export declare type ChangeSet = Map<string, ChangeInfo>; | ||
//# sourceMappingURL=ChangeInfo.d.ts.map |
import { PackageInfo } from './bump'; | ||
import { ChangeInfo } from './ChangeInfo'; | ||
import { ChangeSet } from './ChangeInfo'; | ||
interface ChangelogEntry { | ||
@@ -20,3 +20,3 @@ comment: string; | ||
} | ||
export declare function getPackageChangelogs(changes: ChangeInfo[], packageInfos: { | ||
export declare function getPackageChangelogs(changeSet: ChangeSet, packageInfos: { | ||
[pkg: string]: PackageInfo; | ||
@@ -26,3 +26,3 @@ }): { | ||
}; | ||
export declare function writeChangelog(changes: ChangeInfo[], packageInfos: { | ||
export declare function writeChangelog(changeSet: ChangeSet, packageInfos: { | ||
[pkg: string]: PackageInfo; | ||
@@ -29,0 +29,0 @@ }): void; |
@@ -9,5 +9,5 @@ "use strict"; | ||
const tag_1 = require("./tag"); | ||
function getPackageChangelogs(changes, packageInfos) { | ||
function getPackageChangelogs(changeSet, packageInfos) { | ||
const changelogs = {}; | ||
changes.forEach(change => { | ||
for (let [_, change] of changeSet) { | ||
const { packageName } = change; | ||
@@ -26,8 +26,8 @@ changelogs[packageName] = changelogs[packageName] || { | ||
}); | ||
}); | ||
} | ||
return changelogs; | ||
} | ||
exports.getPackageChangelogs = getPackageChangelogs; | ||
function writeChangelog(changes, packageInfos) { | ||
const changelogs = getPackageChangelogs(changes, packageInfos); | ||
function writeChangelog(changeSet, packageInfos) { | ||
const changelogs = getPackageChangelogs(changeSet, packageInfos); | ||
Object.keys(changelogs).forEach(pkg => { | ||
@@ -34,0 +34,0 @@ const packagePath = path_1.default.dirname(packageInfos[pkg].packageJsonPath); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -60,3 +52,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
(() => __awaiter(this, void 0, void 0, function* () { | ||
(async () => { | ||
// Validation Steps | ||
@@ -104,3 +96,3 @@ if (!validation_1.isGitAvailable(options.path)) { | ||
} | ||
const changes = yield changefile_1.promptForChange(options); | ||
const changes = await changefile_1.promptForChange(options); | ||
if (changes) { | ||
@@ -111,3 +103,3 @@ changefile_1.writeChangeFiles(changes, options.path); | ||
} | ||
}))(); | ||
})(); | ||
function showHelp() { | ||
@@ -114,0 +106,0 @@ const packageJson = require('../package.json'); |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -31,43 +23,39 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
start() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.server) { | ||
throw new Error('Server already started'); | ||
async start() { | ||
if (this.server) { | ||
throw new Error('Server already started'); | ||
} | ||
if (this.port) { | ||
// We've already successfully used this port, so we assume it will work again. (see comments above) | ||
return this.startWithPort(this.port); | ||
} | ||
let tryPort = defaultPort; | ||
while (!this.port) { | ||
// find-free-port will throw an error for us if none are free. No need to explicitly check. | ||
tryPort = await find_free_port_1.default(tryPort, defaultPort + 10); | ||
try { | ||
await this.startWithPort(tryPort); | ||
this.port = tryPort; | ||
} | ||
if (this.port) { | ||
// We've already successfully used this port, so we assume it will work again. (see comments above) | ||
return this.startWithPort(this.port); | ||
catch { | ||
tryPort++; | ||
console.log(`Could not start server, trying again on port ${tryPort}`); | ||
} | ||
let tryPort = defaultPort; | ||
while (!this.port) { | ||
// find-free-port will throw an error for us if none are free. No need to explicitly check. | ||
tryPort = yield find_free_port_1.default(tryPort, defaultPort + 10); | ||
try { | ||
yield this.startWithPort(tryPort); | ||
this.port = tryPort; | ||
} | ||
catch (_a) { | ||
tryPort++; | ||
console.log(`Could not start server, trying again on port ${tryPort}`); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
; | ||
startWithPort(port) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
this.server = child_process_1.spawn(process.execPath, [verdaccioApi, port.toString()]); | ||
this.server.stdout.on('data', (data) => { | ||
if (data.includes('verdaccio running')) { | ||
resolve(); | ||
} | ||
}); | ||
this.server.stderr.on('data', (data) => { | ||
reject(); | ||
}); | ||
this.server.on('error', (data) => { | ||
reject(); | ||
}); | ||
async startWithPort(port) { | ||
return new Promise((resolve, reject) => { | ||
this.server = child_process_1.spawn(process.execPath, [verdaccioApi, port.toString()]); | ||
this.server.stdout.on('data', (data) => { | ||
if (data.includes('verdaccio running')) { | ||
resolve(); | ||
} | ||
}); | ||
this.server.stderr.on('data', (data) => { | ||
reject(); | ||
}); | ||
this.server.on('error', (data) => { | ||
reject(); | ||
}); | ||
}); | ||
@@ -85,8 +73,6 @@ } | ||
*/ | ||
reset() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// Since we're running in memory we can just restart the server. | ||
this.stop(); | ||
yield this.start(); | ||
}); | ||
async reset() { | ||
// Since we're running in memory we can just restart the server. | ||
this.stop(); | ||
await this.start(); | ||
} | ||
@@ -93,0 +79,0 @@ /** |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -33,13 +25,11 @@ if (mod && mod.__esModule) return mod; | ||
}; | ||
function dirAsync(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
tmp.dir(options, (err, name, removeCallback) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
else { | ||
resolve({ name, removeCallback }); | ||
} | ||
}); | ||
async function dirAsync(options) { | ||
return new Promise((resolve, reject) => { | ||
tmp.dir(options, (err, name, removeCallback) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
else { | ||
resolve({ name, removeCallback }); | ||
} | ||
}); | ||
@@ -65,54 +55,46 @@ }); | ||
} | ||
function runCommands(commands) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (let i = 0; i < commands.length; i++) { | ||
try { | ||
yield exec(commands[i]); | ||
} | ||
catch (e) { | ||
console.error('runCommands failed:'); | ||
console.error(e.stdout); | ||
console.error(e.stderr); | ||
console.error(e); | ||
console.error(e.message); | ||
throw e; | ||
} | ||
async function runCommands(commands) { | ||
for (let i = 0; i < commands.length; i++) { | ||
try { | ||
await exec(commands[i]); | ||
} | ||
}); | ||
catch (e) { | ||
console.error('runCommands failed:'); | ||
console.error(e.stdout); | ||
console.error(e.stderr); | ||
console.error(e); | ||
console.error(e.message); | ||
throw e; | ||
} | ||
} | ||
} | ||
function runInDirectory(targetDirectory, commands) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
async function runInDirectory(targetDirectory, commands) { | ||
const originalDirectory = process.cwd(); | ||
process.chdir(targetDirectory); | ||
await runCommands(commands); | ||
process.chdir(originalDirectory); | ||
} | ||
class RepositoryFactory { | ||
async create() { | ||
const originalDirectory = process.cwd(); | ||
process.chdir(targetDirectory); | ||
yield runCommands(commands); | ||
this.root = await dirAsync({ prefix: 'beachball-repository-upstream-' }); | ||
process.chdir(this.root.name); | ||
await runCommands(['git init --bare']); | ||
const tmpRepo = new Repository(); | ||
await tmpRepo.initialize(); | ||
await tmpRepo.cloneFrom(this.root.name); | ||
await tmpRepo.commitChange('README'); | ||
await writeFileAsync(path_1.default.join(tmpRepo.rootPath, 'package.json'), JSON.stringify(exports.packageJsonFixture, null, 2)); | ||
await tmpRepo.commitChange('package.json'); | ||
await tmpRepo.push('origin', 'HEAD:master'); | ||
process.chdir(originalDirectory); | ||
}); | ||
} | ||
class RepositoryFactory { | ||
create() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const originalDirectory = process.cwd(); | ||
this.root = yield dirAsync({ prefix: 'beachball-repository-upstream-' }); | ||
process.chdir(this.root.name); | ||
yield runCommands(['git init --bare']); | ||
const tmpRepo = new Repository(); | ||
yield tmpRepo.initialize(); | ||
yield tmpRepo.cloneFrom(this.root.name); | ||
yield tmpRepo.commitChange('README'); | ||
yield writeFileAsync(path_1.default.join(tmpRepo.rootPath, 'package.json'), JSON.stringify(exports.packageJsonFixture, null, 2)); | ||
yield tmpRepo.commitChange('package.json'); | ||
yield tmpRepo.push('origin', 'HEAD:master'); | ||
process.chdir(originalDirectory); | ||
}); | ||
} | ||
cloneRepository() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.root) { | ||
throw new Error('Must create before cloning'); | ||
} | ||
const newRepo = new Repository(); | ||
yield newRepo.initialize(); | ||
yield newRepo.cloneFrom(this.root.name); | ||
return newRepo; | ||
}); | ||
async cloneRepository() { | ||
if (!this.root) { | ||
throw new Error('Must create before cloning'); | ||
} | ||
const newRepo = new Repository(); | ||
await newRepo.initialize(); | ||
await newRepo.cloneFrom(this.root.name); | ||
return newRepo; | ||
} | ||
@@ -122,6 +104,4 @@ } | ||
class Repository { | ||
initialize() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.root = yield dirAsync({ prefix: 'beachball-repository-cloned-' }); | ||
}); | ||
async initialize() { | ||
this.root = await dirAsync({ prefix: 'beachball-repository-cloned-' }); | ||
} | ||
@@ -134,52 +114,42 @@ get rootPath() { | ||
} | ||
cloneFrom(path, originName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.root) { | ||
throw new Error('Must initialize before cloning'); | ||
} | ||
yield runInDirectory(this.root.name, [ | ||
`git clone ${originName ? '-o ' + originName + ' ' : ''}${path} .`, | ||
'git config user.email ci@example.com', | ||
'git config user.name CIUSER', | ||
]); | ||
this.origin = path; | ||
}); | ||
async cloneFrom(path, originName) { | ||
if (!this.root) { | ||
throw new Error('Must initialize before cloning'); | ||
} | ||
await runInDirectory(this.root.name, [ | ||
`git clone ${originName ? '-o ' + originName + ' ' : ''}${path} .`, | ||
'git config user.email ci@example.com', | ||
'git config user.name CIUSER', | ||
]); | ||
this.origin = path; | ||
} | ||
commitChange(newFilename, content) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.root) { | ||
throw new Error('Must initialize before cloning'); | ||
} | ||
yield fs.ensureFile(path_1.default.join(this.root.name, newFilename)); | ||
if (content) { | ||
yield fs.writeFile(path_1.default.join(this.root.name, newFilename), content); | ||
} | ||
yield runInDirectory(this.root.name, [`git add ${newFilename}`, `git commit -m '${newFilename}'`]); | ||
}); | ||
async commitChange(newFilename, content) { | ||
if (!this.root) { | ||
throw new Error('Must initialize before cloning'); | ||
} | ||
await fs.ensureFile(path_1.default.join(this.root.name, newFilename)); | ||
if (content) { | ||
await fs.writeFile(path_1.default.join(this.root.name, newFilename), content); | ||
} | ||
await runInDirectory(this.root.name, [`git add ${newFilename}`, `git commit -m '${newFilename}'`]); | ||
} | ||
branch(branchName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.root) { | ||
throw new Error('Must initialize before cloning'); | ||
} | ||
yield runInDirectory(this.root.name, [`git checkout -b ${branchName}`]); | ||
}); | ||
async branch(branchName) { | ||
if (!this.root) { | ||
throw new Error('Must initialize before cloning'); | ||
} | ||
await runInDirectory(this.root.name, [`git checkout -b ${branchName}`]); | ||
} | ||
push(remote, branch) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.root) { | ||
throw new Error('Must initialize before push'); | ||
} | ||
yield runInDirectory(this.root.name, [`git push ${remote} ${branch}`]); | ||
}); | ||
async push(remote, branch) { | ||
if (!this.root) { | ||
throw new Error('Must initialize before push'); | ||
} | ||
await runInDirectory(this.root.name, [`git push ${remote} ${branch}`]); | ||
} | ||
cleanUp() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.root) { | ||
throw new Error('Must initialize before clean up'); | ||
} | ||
yield removeAsync(this.root.name); | ||
}); | ||
async cleanUp() { | ||
if (!this.root) { | ||
throw new Error('Must initialize before clean up'); | ||
} | ||
await removeAsync(this.root.name); | ||
} | ||
} | ||
exports.Repository = Repository; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -92,15 +84,14 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.bumpAndPush = bumpAndPush; | ||
function publish(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { path: cwd, branch, registry, tag, message } = options; | ||
// First, validate that we have changes to publish | ||
const changes = changefile_1.readChangeFiles(cwd); | ||
const packageChangeTypes = changefile_1.getPackageChangeTypes(changes); | ||
if (Object.keys(packageChangeTypes).length === 0) { | ||
console.log('Nothing to bump, skipping publish!'); | ||
return; | ||
} | ||
// Collate the changes per package | ||
const currentBranch = git_1.getBranchName(cwd); | ||
console.log(`Publishing with the following configuration: | ||
async function publish(options) { | ||
const { path: cwd, branch, registry, tag, message } = options; | ||
// First, validate that we have changes to publish | ||
const changes = changefile_1.readChangeFiles(cwd); | ||
const packageChangeTypes = changefile_1.getPackageChangeTypes(changes); | ||
if (Object.keys(packageChangeTypes).length === 0) { | ||
console.log('Nothing to bump, skipping publish!'); | ||
return; | ||
} | ||
// Collate the changes per package | ||
const currentBranch = git_1.getBranchName(cwd); | ||
console.log(`Publishing with the following configuration: | ||
@@ -117,38 +108,37 @@ registry: ${registry} | ||
`); | ||
if (!options.yes) { | ||
const response = yield prompts_1.default({ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: 'Is everything correct (use the --yes or -y arg to skip this prompt)?', | ||
}); | ||
if (!response.yes) { | ||
return; | ||
} | ||
if (!options.yes) { | ||
const response = await prompts_1.default({ | ||
type: 'confirm', | ||
name: 'yes', | ||
message: 'Is everything correct (use the --yes or -y arg to skip this prompt)?', | ||
}); | ||
if (!response.yes) { | ||
return; | ||
} | ||
// checkout publish branch | ||
const publishBranch = 'publish_' + String(new Date().getTime()); | ||
git_1.gitFailFast(['checkout', '-b', publishBranch], { cwd }); | ||
console.log('Bumping version for npm publish'); | ||
const bumpInfo = bump_1.gatherBumpInfo(cwd); | ||
// Step 1. Bump + npm publish | ||
// npm / yarn publish | ||
if (options.publish) { | ||
publishToRegistry(bumpInfo, options); | ||
} | ||
else { | ||
console.log('Skipping publish'); | ||
} | ||
// Step 2. | ||
// - reset, fetch latest from origin/master (to ensure less chance of conflict), then bump again + commit | ||
if (branch && options.push) { | ||
bumpAndPush(bumpInfo, publishBranch, options); | ||
} | ||
else { | ||
console.log('Skipping git push and tagging'); | ||
} | ||
if (currentBranch) { | ||
console.log(`git checkout ${currentBranch}`); | ||
git_1.gitFailFast(['checkout', currentBranch], { cwd }); | ||
} | ||
}); | ||
} | ||
// checkout publish branch | ||
const publishBranch = 'publish_' + String(new Date().getTime()); | ||
git_1.gitFailFast(['checkout', '-b', publishBranch], { cwd }); | ||
console.log('Bumping version for npm publish'); | ||
const bumpInfo = bump_1.gatherBumpInfo(cwd); | ||
// Step 1. Bump + npm publish | ||
// npm / yarn publish | ||
if (options.publish) { | ||
publishToRegistry(bumpInfo, options); | ||
} | ||
else { | ||
console.log('Skipping publish'); | ||
} | ||
// Step 2. | ||
// - reset, fetch latest from origin/master (to ensure less chance of conflict), then bump again + commit | ||
if (branch && options.push) { | ||
bumpAndPush(bumpInfo, publishBranch, options); | ||
} | ||
else { | ||
console.log('Skipping git push and tagging'); | ||
} | ||
if (currentBranch) { | ||
console.log(`git checkout ${currentBranch}`); | ||
git_1.gitFailFast(['checkout', currentBranch], { cwd }); | ||
} | ||
} | ||
@@ -155,0 +145,0 @@ exports.publish = publish; |
{ | ||
"name": "beachball", | ||
"version": "1.14.1", | ||
"version": "1.14.2", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -6,3 +6,3 @@ import { getPackageChangeTypes, readChangeFiles, unlinkChangeFiles } from './changefile'; | ||
import semver from 'semver'; | ||
import { ChangeInfo } from './ChangeInfo'; | ||
import { ChangeSet } from './ChangeInfo'; | ||
@@ -20,5 +20,8 @@ export { PackageInfo } from './PackageInfo'; | ||
// Clear non-existent changes | ||
const filteredChanges = changes.filter(change => { | ||
return packageInfos[change.packageName]; | ||
}); | ||
const filteredChanges: ChangeSet = new Map(); | ||
for (let [changeFile, change] of changes) { | ||
if (packageInfos[change.packageName]) { | ||
filteredChanges.set(changeFile, change); | ||
} | ||
} | ||
@@ -41,3 +44,3 @@ // Clear non-existent changeTypes | ||
bumpInfo: { | ||
changes: ChangeInfo[]; | ||
changes: ChangeSet; | ||
packageInfos: ReturnType<typeof getPackageInfos>; | ||
@@ -44,0 +47,0 @@ packageChangeTypes: ReturnType<typeof getPackageChangeTypes>; |
@@ -1,2 +0,2 @@ | ||
import { ChangeInfo, ChangeType } from './ChangeInfo'; | ||
import { ChangeInfo, ChangeType, ChangeSet } from './ChangeInfo'; | ||
import { getChangedPackages } from './getChangedPackages'; | ||
@@ -130,3 +130,2 @@ import { getChangePath } from './paths'; | ||
const change = changes[pkgName]; | ||
change.file = changeFile; | ||
fs.writeFileSync(changeFile, JSON.stringify(change, null, 2)); | ||
@@ -151,6 +150,6 @@ | ||
*/ | ||
export function unlinkChangeFiles(changes: ChangeInfo[], packageInfos: { [pkg: string]: PackageInfo }, cwd: string) { | ||
export function unlinkChangeFiles(changeSet: ChangeSet, packageInfos: { [pkg: string]: PackageInfo }, cwd: string) { | ||
const changePath = getChangePath(cwd); | ||
if (!changePath || !changes) { | ||
if (!changePath || !changeSet) { | ||
return; | ||
@@ -160,6 +159,6 @@ } | ||
console.log('Removing change files:'); | ||
for (const change of changes) { | ||
if (change.file && packageInfos[change.packageName] && !packageInfos[change.packageName].private) { | ||
console.log(`- ${change.file}`); | ||
fs.removeSync(path.join(changePath, change.file)); | ||
for (let [changeFile, change] of changeSet) { | ||
if (changeFile && packageInfos[change.packageName] && !packageInfos[change.packageName].private) { | ||
console.log(`- ${changeFile}`); | ||
fs.removeSync(path.join(changePath, changeFile)); | ||
} | ||
@@ -191,10 +190,10 @@ } | ||
export function readChangeFiles(cwd: string) { | ||
const changeSet: ChangeSet = new Map(); | ||
const changePath = getChangePath(cwd); | ||
if (!changePath || !fs.existsSync(changePath)) { | ||
return []; | ||
return changeSet; | ||
} | ||
const changeFiles = fs.readdirSync(changePath); | ||
const changes: ChangeInfo[] = []; | ||
@@ -204,3 +203,3 @@ changeFiles.forEach(changeFile => { | ||
const packageJson = JSON.parse(fs.readFileSync(path.join(changePath, changeFile)).toString()); | ||
changes.push({ ...packageJson, file: changeFile }); | ||
changeSet.set(changeFile, packageJson); | ||
} catch (e) { | ||
@@ -211,6 +210,6 @@ console.warn(`Invalid change file detected: ${changeFile}`); | ||
return changes; | ||
return changeSet; | ||
} | ||
export function getPackageChangeTypes(changes: ChangeInfo[]) { | ||
export function getPackageChangeTypes(changeSet: ChangeSet) { | ||
const changeTypeWeights = { | ||
@@ -224,7 +223,7 @@ major: 4, | ||
const changePerPackage: { [pkgName: string]: ChangeInfo['type'] } = {}; | ||
changes.forEach(change => { | ||
for (let [_, change] of changeSet) { | ||
const { packageName } = change; | ||
if (change.type === 'none') { | ||
return; | ||
continue; | ||
} | ||
@@ -238,5 +237,5 @@ | ||
} | ||
}); | ||
} | ||
return changePerPackage; | ||
} |
@@ -10,3 +10,4 @@ export type ChangeType = 'prerelease' | 'patch' | 'minor' | 'major' | 'none'; | ||
date: Date; | ||
file?: string; | ||
} | ||
export type ChangeSet = Map<string, ChangeInfo>; |
@@ -5,3 +5,3 @@ import { PackageInfo } from './bump'; | ||
import { generateTag } from './tag'; | ||
import { ChangeInfo } from './ChangeInfo'; | ||
import { ChangeInfo, ChangeSet } from './ChangeInfo'; | ||
@@ -45,5 +45,6 @@ interface ChangelogEntry { | ||
export function getPackageChangelogs(changes: ChangeInfo[], packageInfos: { [pkg: string]: PackageInfo }) { | ||
export function getPackageChangelogs(changeSet: ChangeSet, packageInfos: { [pkg: string]: PackageInfo }) { | ||
const changelogs: { [pkgName: string]: PackageChangelog } = {}; | ||
changes.forEach(change => { | ||
for (let [_, change] of changeSet) { | ||
const { packageName } = change; | ||
@@ -64,3 +65,3 @@ | ||
}); | ||
}); | ||
} | ||
@@ -70,4 +71,4 @@ return changelogs; | ||
export function writeChangelog(changes: ChangeInfo[], packageInfos: { [pkg: string]: PackageInfo }) { | ||
const changelogs = getPackageChangelogs(changes, packageInfos); | ||
export function writeChangelog(changeSet: ChangeSet, packageInfos: { [pkg: string]: PackageInfo }) { | ||
const changelogs = getPackageChangelogs(changeSet, packageInfos); | ||
@@ -74,0 +75,0 @@ Object.keys(changelogs).forEach(pkg => { |
{ | ||
"compilerOptions": { | ||
"outDir": "./lib", | ||
"target": "es2016", | ||
"target": "esnext", | ||
"module": "commonjs", | ||
@@ -6,0 +6,0 @@ "moduleResolution": "node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
196766
4901