New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

beachball

Package Overview
Dependencies
Maintainers
1
Versions
246
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beachball - npm Package Compare versions

Comparing version 1.13.5 to 1.14.0

lib/__tests__/publishGit.test.d.ts

16

CHANGELOG.json

@@ -5,3 +5,17 @@ {

{
"date": "Fri, 27 Sep 2019 23:42:40 GMT",
"date": "Fri, 04 Oct 2019 00:52:12 GMT",
"tag": "beachball_v1.14.0",
"version": "1.14.0",
"comments": {
"minor": [
{
"comment": "Adding robustness in how publish works so merging is safer",
"author": "odbuild@microsoft.com",
"commit": "76425bfb7e76b1471cf7fe1de40930af4ecf4938"
}
]
}
},
{
"date": "Fri, 27 Sep 2019 23:42:49 GMT",
"tag": "beachball_v1.13.5",

@@ -8,0 +22,0 @@ "version": "1.13.5",

10

CHANGELOG.md
# Change Log - beachball
This log was last generated on Fri, 27 Sep 2019 23:42:40 GMT and should not be manually modified.
This log was last generated on Fri, 04 Oct 2019 00:52:12 GMT and should not be manually modified.
## 1.14.0
Fri, 04 Oct 2019 00:52:12 GMT
### Minor changes
- Adding robustness in how publish works so merging is safer (odbuild@microsoft.com)
## 1.13.5
Fri, 27 Sep 2019 23:42:40 GMT
Fri, 27 Sep 2019 23:42:49 GMT

@@ -8,0 +14,0 @@ ### Patches

@@ -64,5 +64,6 @@ "use strict";

}, repository.rootPath);
const changes = changefile_1.readChangeFiles(repository.rootPath);
// Gather all package info from package.json
const packageInfos = monorepo_1.getPackageInfos(repository.rootPath);
changelog_1.writeChangelog(packageInfos, repository.rootPath);
changelog_1.writeChangelog(changes, packageInfos);
const changelogFile = path_1.default.join(repository.rootPath, 'CHANGELOG.md');

@@ -69,0 +70,0 @@ const text = yield readFileAsync(changelogFile, 'utf-8');

@@ -23,3 +23,3 @@ "use strict";

});
describe('npm publish', () => {
describe('packagePublish', () => {
beforeEach(() => __awaiter(this, void 0, void 0, function* () {

@@ -26,0 +26,0 @@ yield registry.reset();

@@ -1,5 +0,30 @@

import { PackageInfo } from './monorepo';
import { getPackageChangeTypes } from './changefile';
import { getPackageInfos, PackageInfo } from './monorepo';
import { ChangeInfo } from './ChangeInfo';
export declare type PackageInfo = PackageInfo;
export declare type BumpInfo = ReturnType<typeof bump>;
export declare function gatherBumpInfo(cwd: string): {
packageChangeTypes: {
[pkgName: string]: import("./ChangeInfo").ChangeType;
};
packageInfos: {
[pkgName: string]: PackageInfo;
};
changes: ChangeInfo[];
};
export declare function performBump(bumpInfo: {
changes: ChangeInfo[];
packageInfos: ReturnType<typeof getPackageInfos>;
packageChangeTypes: ReturnType<typeof getPackageChangeTypes>;
}, cwd: string): {
changes: ChangeInfo[];
packageChangeTypes: {
[pkgName: string]: import("./ChangeInfo").ChangeType;
};
packageInfos: {
[pkgName: string]: PackageInfo;
};
};
export declare function bump(cwd: string): {
changes: ChangeInfo[];
packageChangeTypes: {

@@ -6,0 +31,0 @@ [pkgName: string]: import("./ChangeInfo").ChangeType;

@@ -11,7 +11,26 @@ "use strict";

const semver_1 = __importDefault(require("semver"));
function bump(cwd) {
function gatherBumpInfo(cwd) {
// Collate the changes per package
const packageChangeTypes = changefile_1.getPackageChangeTypes(cwd);
// Gather all package info from package.json
const changes = changefile_1.readChangeFiles(cwd);
const packageChangeTypes = changefile_1.getPackageChangeTypes(changes);
const packageInfos = monorepo_1.getPackageInfos(cwd);
// Clear non-existent changes
const filteredChanges = changes.filter(change => {
return packageInfos[change.packageName];
});
// Clear non-existent changeTypes
Object.keys(packageChangeTypes).forEach(packageName => {
if (!packageInfos[packageName]) {
delete packageChangeTypes[packageName];
}
});
return {
packageChangeTypes,
packageInfos,
changes: filteredChanges,
};
}
exports.gatherBumpInfo = gatherBumpInfo;
function performBump(bumpInfo, cwd) {
const { changes, packageInfos, packageChangeTypes } = bumpInfo;
// Apply package.json version updates

@@ -53,4 +72,7 @@ Object.keys(packageChangeTypes).forEach(pkgName => {

// Generate changelog
changelog_1.writeChangelog(packageInfos, cwd);
changelog_1.writeChangelog(changes, packageInfos);
// Unlink changelogs
changefile_1.unlinkChangeFiles(changes, cwd);
return {
changes,
packageChangeTypes,

@@ -60,2 +82,6 @@ packageInfos,

}
exports.performBump = performBump;
function bump(cwd) {
return performBump(gatherBumpInfo(cwd), cwd);
}
exports.bump = bump;

@@ -62,0 +88,0 @@ function bumpMinSemverRange(minVersion, semverRange) {

@@ -18,7 +18,13 @@ import { ChangeInfo, ChangeType } from './ChangeInfo';

}, cwd: string): void;
export declare function unlinkChangeFiles(cwd: string): void;
/**
* Unlink only change files that are specified in the changes param
*
* @param changes existing change files to be removed
* @param cwd
*/
export declare function unlinkChangeFiles(changes: ChangeInfo[], cwd: string): void;
export declare function readChangeFiles(cwd: string): ChangeInfo[];
export declare function getPackageChangeTypes(cwd: string): {
export declare function getPackageChangeTypes(changes: ChangeInfo[]): {
[pkgName: string]: ChangeType;
};
//# sourceMappingURL=changefile.d.ts.map

@@ -46,4 +46,4 @@ "use strict";

{ value: 'none', title: ' None - this change does not affect the published package in any way.' },
{ value: 'major', title: ' Major - major feature; breaking changes.' }
].filter(choice => !packageInfos[pkg].disallowedChangeTypes.includes(choice.value))
{ value: 'major', title: ' Major - major feature; breaking changes.' },
].filter(choice => !packageInfos[pkg].disallowedChangeTypes.includes(choice.value)),
};

@@ -64,9 +64,12 @@ if (changeTypePrompt.choices.length === 0) {

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] : [])];
const questions = [
...(showChangeTypePrompt ? [changeTypePrompt] : []),
...(!options.message ? [descriptionPrompt] : []),
];
let response = {
type: options.type || 'none',
comment: options.message || ''
comment: options.message || '',
};

@@ -114,4 +117,5 @@ if (questions.length > 0) {

const change = changes[pkgName];
change.file = changeFile;
fs_extra_1.default.writeFileSync(changeFile, JSON.stringify(change, null, 2));
changeFiles.push(changeFile);
fs_extra_1.default.writeFileSync(changeFile, JSON.stringify(change, null, 2));
});

@@ -125,8 +129,24 @@ git_1.stageAndCommit(changeFiles, 'Change files', cwd);

exports.writeChangeFiles = writeChangeFiles;
function unlinkChangeFiles(cwd) {
/**
* Unlink only change files that are specified in the changes param
*
* @param changes existing change files to be removed
* @param cwd
*/
function unlinkChangeFiles(changes, cwd) {
const changePath = paths_1.getChangePath(cwd);
if (!changePath) {
if (!changePath || !changes) {
return;
}
fs_extra_1.default.removeSync(changePath);
console.log('Removing change files:');
for (const change of changes) {
if (change.file) {
console.log(`- ${change.file}`);
fs_extra_1.default.removeSync(path_1.default.join(changePath, change.file));
}
}
if (fs_extra_1.default.existsSync(changePath) && fs_extra_1.default.readdirSync(changePath).length === 0) {
console.log('Removing change path');
fs_extra_1.default.removeSync(changePath);
}
}

@@ -145,3 +165,3 @@ exports.unlinkChangeFiles = unlinkChangeFiles;

leftPadTwoZeros(date.getMinutes().toString()),
leftPadTwoZeros(date.getSeconds().toString())
leftPadTwoZeros(date.getSeconds().toString()),
].join('-');

@@ -158,3 +178,4 @@ }

try {
changes.push(JSON.parse(fs_extra_1.default.readFileSync(path_1.default.join(changePath, changeFile)).toString()));
const packageJson = JSON.parse(fs_extra_1.default.readFileSync(path_1.default.join(changePath, changeFile)).toString());
changes.push(Object.assign({}, packageJson, { file: changeFile }));
}

@@ -168,3 +189,3 @@ catch (e) {

exports.readChangeFiles = readChangeFiles;
function getPackageChangeTypes(cwd) {
function getPackageChangeTypes(changes) {
const changeTypeWeights = {

@@ -175,5 +196,4 @@ major: 4,

prerelease: 1,
none: 0
none: 0,
};
const changes = readChangeFiles(cwd);
const changePerPackage = {};

@@ -185,3 +205,4 @@ changes.forEach(change => {

}
if (!changePerPackage[packageName] || changeTypeWeights[change.type] > changeTypeWeights[changePerPackage[packageName]]) {
if (!changePerPackage[packageName] ||
changeTypeWeights[change.type] > changeTypeWeights[changePerPackage[packageName]]) {
changePerPackage[packageName] = change.type;

@@ -188,0 +209,0 @@ }

@@ -9,3 +9,4 @@ export declare type ChangeType = 'prerelease' | 'patch' | 'minor' | 'major' | 'none';

date: Date;
file?: string;
}
//# sourceMappingURL=ChangeInfo.d.ts.map
import { PackageInfo } from './bump';
import { ChangeInfo } from './ChangeInfo';
interface ChangelogEntry {

@@ -19,11 +20,11 @@ comment: string;

}
export declare function getPackageChangelogs(packageInfos: {
export declare function getPackageChangelogs(changes: ChangeInfo[], packageInfos: {
[pkg: string]: PackageInfo;
}, cwd: string): {
}): {
[pkgName: string]: PackageChangelog;
};
export declare function writeChangelog(packageInfos: {
export declare function writeChangelog(changes: ChangeInfo[], packageInfos: {
[pkg: string]: PackageInfo;
}, cwd: string): void;
}): void;
export {};
//# sourceMappingURL=changelog.d.ts.map

@@ -6,8 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const changefile_1 = require("./changefile");
const path_1 = __importDefault(require("path"));
const fs_1 = __importDefault(require("fs"));
const tag_1 = require("./tag");
function getPackageChangelogs(packageInfos, cwd) {
const changes = changefile_1.readChangeFiles(cwd);
function getPackageChangelogs(changes, packageInfos) {
const changelogs = {};

@@ -32,4 +30,4 @@ changes.forEach(change => {

exports.getPackageChangelogs = getPackageChangelogs;
function writeChangelog(packageInfos, cwd) {
const changelogs = getPackageChangelogs(packageInfos, cwd);
function writeChangelog(changes, packageInfos) {
const changelogs = getPackageChangelogs(changes, packageInfos);
Object.keys(changelogs).forEach(pkg => {

@@ -58,3 +56,2 @@ const packagePath = path_1.default.dirname(packageInfos[pkg].packageJsonPath);

});
changefile_1.unlinkChangeFiles(cwd);
}

@@ -61,0 +58,0 @@ exports.writeChangelog = writeChangelog;

@@ -17,3 +17,3 @@ import * as tmp from 'tmp';

cloneFrom(path: string, originName?: string): Promise<void>;
commitChange(newFilename: string): Promise<void>;
commitChange(newFilename: string, content?: string): Promise<void>;
branch(branchName: string): Promise<void>;

@@ -20,0 +20,0 @@ push(remote: string, branch: string): Promise<void>;

@@ -144,3 +144,3 @@ "use strict";

}
commitChange(newFilename) {
commitChange(newFilename, content) {
return __awaiter(this, void 0, void 0, function* () {

@@ -151,2 +151,5 @@ if (!this.root) {

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}'`]);

@@ -153,0 +156,0 @@ });

@@ -0,3 +1,6 @@

import { BumpInfo } from './bump';
import { CliOptions } from './CliOptions';
export declare function publishToRegistry(bumpInfo: BumpInfo, options: CliOptions): void;
export declare function bumpAndPush(bumpInfo: BumpInfo, publishBranch: string, options: CliOptions): void;
export declare function publish(options: CliOptions): Promise<void>;
//# sourceMappingURL=publish.d.ts.map

@@ -20,6 +20,5 @@ "use strict";

const changefile_1 = require("./changefile");
function publishToRegistry(options) {
function publishToRegistry(bumpInfo, options) {
const { path: cwd, registry, tag, token, access } = options;
console.log('Bumping version for npm publish');
const bumpInfo = bump_1.bump(cwd);
bump_1.performBump(bumpInfo, cwd);
if (!validatePackageVersions(bumpInfo, registry)) {

@@ -32,20 +31,27 @@ displayManualRecovery(bumpInfo);

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!');
if (!packageInfo.private) {
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;
}
}
else {
displayManualRecovery(bumpInfo);
console.error(result.stderr);
process.exit(1);
return;
console.warn(`Skipping publish of ${packageInfo.name} since it is marked private. Version has been bumped to ${packageInfo.version}`);
}
});
console.log('Reverting');
git_1.revertLocalChanges(cwd);
return;
}
function bumpAndPush(publishBranch, options) {
exports.publishToRegistry = publishToRegistry;
function bumpAndPush(bumpInfo, publishBranch, options) {
const { path: cwd, branch, tag, message } = options;
const { remote, remoteBranch } = git_1.parseRemoteBranch(branch);
console.log('Reverting');
git_1.revertLocalChanges(cwd);
console.log('Fetching from remote');

@@ -62,3 +68,3 @@ // pull in latest from origin branch

console.log('Bumping the versions for git push');
const bumpInfo = bump_1.bump(cwd);
bump_1.performBump(bumpInfo, cwd);
// checkin

@@ -88,2 +94,3 @@ const mergePublishBranchResult = mergePublishBranch(publishBranch, branch, message, cwd);

}
exports.bumpAndPush = bumpAndPush;
function publish(options) {

@@ -93,3 +100,4 @@ return __awaiter(this, void 0, void 0, function* () {

// First, validate that we have changes to publish
const packageChangeTypes = changefile_1.getPackageChangeTypes(cwd);
const changes = changefile_1.readChangeFiles(cwd);
const packageChangeTypes = changefile_1.getPackageChangeTypes(changes);
if (Object.keys(packageChangeTypes).length === 0) {

@@ -126,6 +134,8 @@ console.log('Nothing to bump, skipping publish!');

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(options);
publishToRegistry(bumpInfo, options);
}

@@ -138,3 +148,3 @@ else {

if (branch && options.push) {
bumpAndPush(publishBranch, options);
bumpAndPush(bumpInfo, publishBranch, options);
}

@@ -141,0 +151,0 @@ else {

{
"name": "beachball",
"version": "1.13.5",
"version": "1.14.0",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -9,3 +9,3 @@ import path from 'path';

import { writeChangeFiles } from '../changefile';
import { writeChangeFiles, readChangeFiles } from '../changefile';
import { getPackageInfos } from '../monorepo';

@@ -70,6 +70,8 @@

const changes = readChangeFiles(repository.rootPath);
// Gather all package info from package.json
const packageInfos = getPackageInfos(repository.rootPath);
writeChangelog(packageInfos, repository.rootPath);
writeChangelog(changes, packageInfos);

@@ -76,0 +78,0 @@ const changelogFile = path.join(repository.rootPath, 'CHANGELOG.md');

@@ -17,3 +17,3 @@ import { Registry } from '../fixtures/registry';

describe('npm publish', () => {
describe('packagePublish', () => {
beforeEach(async () => {

@@ -20,0 +20,0 @@ await registry.reset();

@@ -1,2 +0,2 @@

import { getPackageChangeTypes } from './changefile';
import { getPackageChangeTypes, readChangeFiles, unlinkChangeFiles } from './changefile';
import { getPackageInfos, PackageInfo } from './monorepo';

@@ -6,2 +6,3 @@ import { writeChangelog } from './changelog';

import semver from 'semver';
import { ChangeInfo } from './ChangeInfo';

@@ -12,9 +13,37 @@ export type PackageInfo = PackageInfo;

export function bump(cwd: string) {
export function gatherBumpInfo(cwd: string) {
// Collate the changes per package
const packageChangeTypes = getPackageChangeTypes(cwd);
// Gather all package info from package.json
const changes = readChangeFiles(cwd);
const packageChangeTypes = getPackageChangeTypes(changes);
const packageInfos = getPackageInfos(cwd);
// Clear non-existent changes
const filteredChanges = changes.filter(change => {
return packageInfos[change.packageName];
});
// Clear non-existent changeTypes
Object.keys(packageChangeTypes).forEach(packageName => {
if (!packageInfos[packageName]) {
delete packageChangeTypes[packageName];
}
});
return {
packageChangeTypes,
packageInfos,
changes: filteredChanges,
};
}
export function performBump(
bumpInfo: {
changes: ChangeInfo[];
packageInfos: ReturnType<typeof getPackageInfos>;
packageChangeTypes: ReturnType<typeof getPackageChangeTypes>;
},
cwd: string
) {
const { changes, packageInfos, packageChangeTypes } = bumpInfo;
// Apply package.json version updates

@@ -65,5 +94,9 @@ Object.keys(packageChangeTypes).forEach(pkgName => {

// Generate changelog
writeChangelog(packageInfos, cwd);
writeChangelog(changes, packageInfos);
// Unlink changelogs
unlinkChangeFiles(changes, cwd);
return {
changes,
packageChangeTypes,

@@ -74,2 +107,6 @@ packageInfos,

export function bump(cwd: string) {
return performBump(gatherBumpInfo(cwd), cwd);
}
function bumpMinSemverRange(minVersion: string, semverRange: string) {

@@ -76,0 +113,0 @@ if (semverRange.startsWith('~') || semverRange.startsWith('^')) {

@@ -39,4 +39,4 @@ import { ChangeInfo, ChangeType } from './ChangeInfo';

{ value: 'none', title: ' None - this change does not affect the published package in any way.' },
{ value: 'major', title: ' Major - major feature; breaking changes.' }
].filter(choice => !packageInfos[pkg].disallowedChangeTypes.includes(choice.value))
{ value: 'major', title: ' Major - major feature; breaking changes.' },
].filter(choice => !packageInfos[pkg].disallowedChangeTypes.includes(choice.value)),
};

@@ -60,3 +60,3 @@

return Promise.resolve([...recentMessages.filter(msg => msg.startsWith(input)), input]);
}
},
};

@@ -66,7 +66,10 @@

const questions = [...(showChangeTypePrompt ? [changeTypePrompt] : []), ...(!options.message ? [descriptionPrompt] : [])];
const questions = [
...(showChangeTypePrompt ? [changeTypePrompt] : []),
...(!options.message ? [descriptionPrompt] : []),
];
let response: { comment: string; type: ChangeType } = {
type: options.type || 'none',
comment: options.message || ''
comment: options.message || '',
};

@@ -88,3 +91,3 @@

commit: getCurrentHash(cwd) || 'hash not available',
date: new Date()
date: new Date(),
};

@@ -130,4 +133,6 @@ }

const change = changes[pkgName];
change.file = changeFile;
fs.writeFileSync(changeFile, JSON.stringify(change, null, 2));
changeFiles.push(changeFile);
fs.writeFileSync(changeFile, JSON.stringify(change, null, 2));
});

@@ -143,10 +148,27 @@

export function unlinkChangeFiles(cwd: string) {
/**
* Unlink only change files that are specified in the changes param
*
* @param changes existing change files to be removed
* @param cwd
*/
export function unlinkChangeFiles(changes: ChangeInfo[], cwd: string) {
const changePath = getChangePath(cwd);
if (!changePath) {
if (!changePath || !changes) {
return;
}
fs.removeSync(changePath);
console.log('Removing change files:');
for (const change of changes) {
if (change.file) {
console.log(`- ${change.file}`);
fs.removeSync(path.join(changePath, change.file));
}
}
if (fs.existsSync(changePath) && fs.readdirSync(changePath).length === 0) {
console.log('Removing change path');
fs.removeSync(changePath);
}
}

@@ -166,3 +188,3 @@

leftPadTwoZeros(date.getMinutes().toString()),
leftPadTwoZeros(date.getSeconds().toString())
leftPadTwoZeros(date.getSeconds().toString()),
].join('-');

@@ -183,3 +205,4 @@ }

try {
changes.push(JSON.parse(fs.readFileSync(path.join(changePath, changeFile)).toString()));
const packageJson = JSON.parse(fs.readFileSync(path.join(changePath, changeFile)).toString());
changes.push({ ...packageJson, file: changeFile });
} catch (e) {

@@ -193,3 +216,3 @@ console.warn(`Invalid change file detected: ${changeFile}`);

export function getPackageChangeTypes(cwd: string) {
export function getPackageChangeTypes(changes: ChangeInfo[]) {
const changeTypeWeights = {

@@ -200,5 +223,4 @@ major: 4,

prerelease: 1,
none: 0
none: 0,
};
const changes = readChangeFiles(cwd);
const changePerPackage: { [pkgName: string]: ChangeInfo['type'] } = {};

@@ -212,3 +234,6 @@ changes.forEach(change => {

if (!changePerPackage[packageName] || changeTypeWeights[change.type] > changeTypeWeights[changePerPackage[packageName]]) {
if (
!changePerPackage[packageName] ||
changeTypeWeights[change.type] > changeTypeWeights[changePerPackage[packageName]]
) {
changePerPackage[packageName] = change.type;

@@ -215,0 +240,0 @@ }

@@ -10,2 +10,3 @@ export type ChangeType = 'prerelease' | 'patch' | 'minor' | 'major' | 'none';

date: Date;
file?: string;
}

@@ -1,2 +0,1 @@

import { readChangeFiles, unlinkChangeFiles } from './changefile';
import { PackageInfo } from './bump';

@@ -6,2 +5,3 @@ import path from 'path';

import { generateTag } from './tag';
import { ChangeInfo } from './ChangeInfo';

@@ -45,4 +45,3 @@ interface ChangelogEntry {

export function getPackageChangelogs(packageInfos: { [pkg: string]: PackageInfo }, cwd: string) {
const changes = readChangeFiles(cwd);
export function getPackageChangelogs(changes: ChangeInfo[], packageInfos: { [pkg: string]: PackageInfo }) {
const changelogs: { [pkgName: string]: PackageChangelog } = {};

@@ -70,4 +69,4 @@ changes.forEach(change => {

export function writeChangelog(packageInfos: { [pkg: string]: PackageInfo }, cwd: string) {
const changelogs = getPackageChangelogs(packageInfos, cwd);
export function writeChangelog(changes: ChangeInfo[], packageInfos: { [pkg: string]: PackageInfo }) {
const changelogs = getPackageChangelogs(changes, packageInfos);

@@ -100,4 +99,2 @@ Object.keys(changelogs).forEach(pkg => {

});
unlinkChangeFiles(cwd);
}

@@ -104,0 +101,0 @@

@@ -136,3 +136,3 @@ import { exec as nativeExec } from 'child_process';

async commitChange(newFilename: string) {
async commitChange(newFilename: string, content?: string) {
if (!this.root) {

@@ -144,2 +144,6 @@ throw new Error('Must initialize before cloning');

if (content) {
await fs.writeFile(path.join(this.root.name, newFilename), content);
}
await runInDirectory(this.root.name, [`git add ${newFilename}`, `git commit -m '${newFilename}'`]);

@@ -146,0 +150,0 @@ }

@@ -1,2 +0,2 @@

import { bump, BumpInfo } from './bump';
import { bump, BumpInfo, performBump, gatherBumpInfo } from './bump';
import { CliOptions } from './CliOptions';

@@ -7,9 +7,9 @@ import { git, gitFailFast, revertLocalChanges, parseRemoteBranch, getBranchName } from './git';

import { generateTag } from './tag';
import { getPackageChangeTypes } from './changefile';
import { getPackageChangeTypes, readChangeFiles } from './changefile';
function publishToRegistry(options: CliOptions) {
export function publishToRegistry(bumpInfo: BumpInfo, options: CliOptions) {
const { path: cwd, registry, tag, token, access } = options;
console.log('Bumping version for npm publish');
const bumpInfo = bump(cwd);
performBump(bumpInfo, cwd);
if (!validatePackageVersions(bumpInfo, registry)) {

@@ -23,21 +23,31 @@ displayManualRecovery(bumpInfo);

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!');
if (!packageInfo.private) {
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;
}
} else {
displayManualRecovery(bumpInfo);
console.error(result.stderr);
process.exit(1);
return;
console.warn(
`Skipping publish of ${packageInfo.name} since it is marked private. Version has been bumped to ${packageInfo.version}`
);
}
});
console.log('Reverting');
revertLocalChanges(cwd);
return;
}
function bumpAndPush(publishBranch: string, options: CliOptions) {
export function bumpAndPush(bumpInfo: BumpInfo, publishBranch: string, options: CliOptions) {
const { path: cwd, branch, tag, message } = options;
const { remote, remoteBranch } = parseRemoteBranch(branch);
console.log('Reverting');
revertLocalChanges(cwd);
console.log('Fetching from remote');

@@ -56,3 +66,3 @@

console.log('Bumping the versions for git push');
const bumpInfo = bump(cwd);
performBump(bumpInfo, cwd);

@@ -91,3 +101,4 @@ // checkin

// First, validate that we have changes to publish
const packageChangeTypes = getPackageChangeTypes(cwd);
const changes = readChangeFiles(cwd);
const packageChangeTypes = getPackageChangeTypes(changes);
if (Object.keys(packageChangeTypes).length === 0) {

@@ -130,6 +141,9 @@ console.log('Nothing to bump, skipping publish!');

console.log('Bumping version for npm publish');
const bumpInfo = gatherBumpInfo(cwd);
// Step 1. Bump + npm publish
// npm / yarn publish
if (options.publish) {
publishToRegistry(options);
publishToRegistry(bumpInfo, options);
} else {

@@ -142,3 +156,3 @@ console.log('Skipping publish');

if (branch && options.push) {
bumpAndPush(publishBranch, options);
bumpAndPush(bumpInfo, publishBranch, options);
} else {

@@ -211,2 +225,3 @@ console.log('Skipping git push and tagging');

const packageInfo = bumpInfo.packageInfos[pkg];
process.stdout.write(`Validating package version - ${packageInfo.name}@${packageInfo.version}`);

@@ -213,0 +228,0 @@

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc