Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/build/src/npm-packages/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { bumpAuxiliaryPackages } from './bump';
export { publishNpmPackages } from './publish';
export { publishToNpm } from './publish';
14 changes: 7 additions & 7 deletions packages/build/src/npm-packages/publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { expect } from 'chai';
import path from 'path';
import type { SinonStub } from 'sinon';
import sinon from 'sinon';
import { publishNpmPackages } from './publish';
import { publishToNpm } from './publish';

describe('npm-packages publishNpmPackages', function () {
describe('npm-packages publishToNpm', function () {
let listNpmPackages: SinonStub;
let markBumpedFilesAsAssumeUnchanged: SinonStub;
let spawnSync: SinonStub;
Expand All @@ -30,7 +30,7 @@ describe('npm-packages publishNpmPackages', function () {
listNpmPackages.returns(packages);

expect(() =>
publishNpmPackages(
publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
Expand All @@ -46,7 +46,7 @@ describe('npm-packages publishNpmPackages', function () {
];
listNpmPackages.returns(packages);

publishNpmPackages(
publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
Expand All @@ -64,7 +64,7 @@ describe('npm-packages publishNpmPackages', function () {
];
listNpmPackages.returns(packages);

publishNpmPackages(
publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: true },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
Expand All @@ -88,7 +88,7 @@ describe('npm-packages publishNpmPackages', function () {
];
listNpmPackages.returns(packages);

publishNpmPackages(
publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('npm-packages publishNpmPackages', function () {
spawnSync.throws(new Error('meeep'));

try {
publishNpmPackages(
publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/npm-packages/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { listNpmPackages as listNpmPackagesFn } from './list';
import { spawnSync as spawnSyncFn } from '../helpers/spawn-sync';
import type { SpawnSyncOptionsWithStringEncoding } from 'child_process';

export function publishNpmPackages(
export function publishToNpm(
{ isDryRun = false, useAuxiliaryPackagesOnly = false },
listNpmPackages: typeof listNpmPackagesFn = listNpmPackagesFn,
markBumpedFilesAsAssumeUnchangedFn: typeof markBumpedFilesAsAssumeUnchanged = markBumpedFilesAsAssumeUnchanged,
Expand Down
11 changes: 11 additions & 0 deletions packages/build/src/publish-auxiliary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Config } from './config';
import { publishToNpm } from './npm-packages';

export function publishAuxiliaryPackages(config: Config) {
if (!config.useAuxiliaryPackagesOnly) {
throw new Error(
'This should only be used when publishing auxiliary packages'
);
}
publishToNpm(config);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type {
import type { createAndPublishDownloadCenterConfig as createAndPublishDownloadCenterConfigFn } from './download-center';
import { GithubRepo } from '@mongodb-js/devtools-github-repo';
import type { publishToHomebrew as publishToHomebrewType } from './homebrew';
import type { publishNpmPackages as publishNpmPackagesType } from './npm-packages';
import { runPublish } from './run-publish';
import type { publishToNpm as publishToNpmType } from './npm-packages';
import { publishMongosh } from './publish-mongosh';
import { dummyConfig } from '../test/helpers';

chai.use(require('sinon-chai'));
Expand All @@ -26,10 +26,10 @@ function createStubBarque(overrides?: any): Barque {
return sinon.createStubInstance(Barque, overrides) as unknown as Barque;
}

describe('publish', function () {
describe('publishMongosh', function () {
let config: Config;
let createAndPublishDownloadCenterConfig: typeof createAndPublishDownloadCenterConfigFn;
let publishNpmPackages: typeof publishNpmPackagesType;
let publishToNpm: typeof publishToNpmType;
let writeBuildInfo: typeof writeBuildInfoType;
let publishToHomebrew: typeof publishToHomebrewType;
let shouldDoPublicRelease: typeof shouldDoPublicReleaseFn;
Expand All @@ -42,7 +42,7 @@ describe('publish', function () {
config = { ...dummyConfig };

createAndPublishDownloadCenterConfig = sinon.spy();
publishNpmPackages = sinon.spy();
publishToNpm = sinon.spy();
writeBuildInfo = sinon.spy();
publishToHomebrew = sinon.spy();
shouldDoPublicRelease = sinon.spy();
Expand Down Expand Up @@ -78,14 +78,14 @@ describe('publish', function () {
getMostRecentDraftTagForRelease: sinon.stub().resolves(undefined),
});
try {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -103,14 +103,14 @@ describe('publish', function () {
.resolves({ name: 'v0.7.0-draft.42', sha: 'wrong' }),
});
try {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -123,14 +123,14 @@ describe('publish', function () {
});

it('publishes artifacts to barque', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -153,14 +153,14 @@ describe('publish', function () {
});

it('updates the download center config', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -175,14 +175,14 @@ describe('publish', function () {
});

it('promotes the release in github', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -192,34 +192,32 @@ describe('publish', function () {
});

it('writes analytics config and then publishes NPM packages', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
);

expect(writeBuildInfo).to.have.been.calledOnceWith(config);
expect(publishNpmPackages).to.have.been.calledWith();
expect(publishNpmPackages).to.have.been.calledAfter(
writeBuildInfo as any
);
expect(publishToNpm).to.have.been.calledWith();
expect(publishToNpm).to.have.been.calledAfter(writeBuildInfo as any);
});
it('publishes to homebrew', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -242,14 +240,14 @@ describe('publish', function () {
});

it('does not update the download center config', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -259,14 +257,14 @@ describe('publish', function () {
});

it('does not promote the release in github', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -276,31 +274,31 @@ describe('publish', function () {
});

it('does not publish npm packages', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
);

expect(publishNpmPackages).not.to.have.been.called;
expect(publishToNpm).not.to.have.been.called;
});

it('does not publish to homebrew', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand All @@ -310,14 +308,14 @@ describe('publish', function () {
});

it('does not release to barque', async function () {
await runPublish(
await publishMongosh(
config,
githubRepo,
mongoHomebrewCoreForkRepo,
homebrewCoreRepo,
barque,
createAndPublishDownloadCenterConfig,
publishNpmPackages,
publishToNpm,
writeBuildInfo,
publishToHomebrew,
shouldDoPublicRelease
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import type { createAndPublishDownloadCenterConfig as createAndPublishDownloadCe
import { getArtifactUrl as getArtifactUrlFn } from './evergreen';
import type { GithubRepo } from '@mongodb-js/devtools-github-repo';
import type { publishToHomebrew as publishToHomebrewType } from './homebrew';
import type { publishNpmPackages as publishNpmPackagesType } from './npm-packages';
import type { publishToNpm as publishToNpmType } from './npm-packages';
import type { PackageInformationProvider } from './packaging';
import { getPackageFile } from './packaging';

export async function runPublish(
export async function publishMongosh(
config: Config,
mongoshGithubRepo: GithubRepo,
mongodbHomebrewForkGithubRepo: GithubRepo,
homebrewCoreGithubRepo: GithubRepo,
barque: Barque,
createAndPublishDownloadCenterConfig: typeof createAndPublishDownloadCenterConfigFn,
publishNpmPackages: typeof publishNpmPackagesType,
publishToNpm: typeof publishToNpmType,
writeBuildInfo: typeof writeBuildInfoType,
publishToHomebrew: typeof publishToHomebrewType,
shouldDoPublicRelease: typeof shouldDoPublicReleaseFn = shouldDoPublicReleaseFn,
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function runPublish(
// ensures the segment api key to be present in the published packages
await writeBuildInfo(config, 'packaged');

publishNpmPackages({
publishToNpm({
isDryRun: config.isDryRun,
useAuxiliaryPackagesOnly: config.useAuxiliaryPackagesOnly,
});
Expand Down
Loading
Loading