Skip to content

Commit c5c1fdc

Browse files
authored
chore(build) add to check and fix errors (#348)
1 parent 7139dbb commit c5c1fdc

21 files changed

+72
-82
lines changed

packages/build/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@ const artifact = await createTarball(
177177
);
178178
```
179179

180-
## Installation
181-
```shell
182-
npm install --save @mongosh/build
183-
```
184-
185180
[evergreen-url]: https://evergreen.mongodb.com/waterfall/mongosh
186181
[config-url]: https://github.com/mongodb-js/mongosh/blob/393b505c179b64fbb72e0481c63f1723a3c56f06/config/build.conf.js
187182
[build-img]: ./build.png

packages/build/examples/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.log('Hello World!');
1+
console.info('Hello World!');

packages/build/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"compile-ts": "tsc -p tsconfig.json",
1717
"prepublish": "npm run compile-ts",
1818
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 15000 --colors -r ts-node/register \"./src/**/*.spec.ts\"",
19-
"test-ci": "mocha -r \"../../scripts/import-expansions.js\" --timeout 15000 -r ts-node/register \"./src/**/*.spec.ts\""
19+
"test-ci": "mocha -r \"../../scripts/import-expansions.js\" --timeout 15000 -r ts-node/register \"./src/**/*.spec.ts\"",
20+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
21+
"check": "npm run lint"
2022
},
2123
"license": "Apache-2.0",
2224
"publishConfig": {

packages/build/src/analytics.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import path from 'path';
21
import { expect } from 'chai';
32
import { createAnalyticsConfig } from './analytics';
43

packages/build/src/analytics.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import util from 'util'
1+
import util from 'util';
22
import fs from 'fs';
33
import handlebars from 'handlebars';
44

55
/**
66
* The template.
77
*/
8-
const TEMPLATE = `module.exports = { SEGMENT_API_KEY: "{{segmentKey}}" };`;
8+
const TEMPLATE = 'module.exports = { SEGMENT_API_KEY: "{{segmentKey}}" };';
99

1010
/**
1111
* Create the analytics config.
@@ -27,7 +27,7 @@ const createAnalyticsConfig = (segmentKey: string): string => {
2727
*/
2828
const writeAnalyticsConfig = (file: string, segmentKey: string) => {
2929
const template = createAnalyticsConfig(segmentKey);
30-
console.log('mongosh: writing analytics template:', file);
30+
console.info('mongosh: writing analytics template:', file);
3131
// Cannot use fs/promises on Cygwin.
3232
return util.promisify(fs.writeFile)(file, template);
3333
};

packages/build/src/barque.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ describe('Barque', () => {
152152
it('creates tmp directory that exists', async() => {
153153
const curatorDirPath = await barque.createCuratorDir();
154154

155-
let accessErr
155+
let accessErr;
156156
try {
157-
await fs.access(curatorDirPath)
157+
await fs.access(curatorDirPath);
158158
} catch (e) {
159-
accessErr = e
159+
accessErr = e;
160160
}
161161
// eslint-disable-next-line
162162
expect(accessErr).to.be.undefined
@@ -170,11 +170,11 @@ describe('Barque', () => {
170170

171171
await barque.extractLatestCurator(curatorDirPath);
172172

173-
let accessErr
173+
let accessErr;
174174
try {
175-
await fs.access(curatorPath)
175+
await fs.access(curatorPath);
176176
} catch (e) {
177-
accessErr = e
177+
accessErr = e;
178178
}
179179
// eslint-disable-next-line
180180
expect(accessErr).to.be.undefined

packages/build/src/barque.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import BuildVariant from './build-variant';
2-
import child_process from 'child_process';
2+
import childProcess from 'child_process';
33
import gunzip from 'gunzip-maybe';
44
import Platform from './platform';
55
import fetch from 'node-fetch';
@@ -12,13 +12,13 @@ import util from 'util';
1212
import path from 'path';
1313

1414
const pipeline = util.promisify(stream.pipeline);
15-
const execFile = util.promisify(child_process.execFile);
15+
const execFile = util.promisify(childProcess.execFile);
1616

1717
const LATEST_CURATOR =
1818
'https://s3.amazonaws.com/boxes.10gen.com/build/curator/curator-dist-ubuntu1604-latest.tar.gz';
1919

20-
// make sure everything written in /tmp is cleared if an uncaught exception occurs
21-
tmp.setGracefulCleanup()
20+
// make sure everything written in /tmp is cleared if an uncaught exception occurs
21+
tmp.setGracefulCleanup();
2222

2323
/**
2424
* Distro enum to be used when making a curator call.
@@ -180,7 +180,7 @@ export class Barque {
180180
*
181181
*/
182182
async extractLatestCurator(dest: string): Promise<any> {
183-
const response = await fetch(LATEST_CURATOR)
183+
const response = await fetch(LATEST_CURATOR);
184184
if (response.ok) {
185185
return pipeline(
186186
response.body,

packages/build/src/build-and-upload.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('buildAndRelease', () => {
6363
});
6464

6565
[true, false].forEach((isPublicRelease) => {
66-
it(`uploads the artifact to evergreen if is ${isPublicRelease ? 'a' : 'not a'} public release`, async () => {
66+
it(`uploads the artifact to evergreen if is ${isPublicRelease ? 'a' : 'not a'} public release`, async() => {
6767
githubRepo = createStubRepo({
6868
shouldDoPublicRelease: sinon.stub().returns(Promise.resolve(isPublicRelease))
6969
});
@@ -91,7 +91,7 @@ describe('buildAndRelease', () => {
9191
});
9292
});
9393

94-
it('releases to github if a public release', async () => {
94+
it('releases to github if a public release', async() => {
9595
githubRepo = createStubRepo({
9696
shouldDoPublicRelease: sinon.stub().resolves(true)
9797
});
@@ -116,7 +116,7 @@ describe('buildAndRelease', () => {
116116
);
117117
});
118118

119-
it('does not release to github if not a public release', async () => {
119+
it('does not release to github if not a public release', async() => {
120120
githubRepo = createStubRepo({
121121
shouldDoPublicRelease: sinon.stub().resolves(false)
122122
});
@@ -137,7 +137,7 @@ describe('buildAndRelease', () => {
137137
expect(uploadToDownloadCenter).to.not.have.been.called;
138138
});
139139

140-
it('releases to barque if a public release', async () => {
140+
it('releases to barque if a public release', async() => {
141141
githubRepo = createStubRepo({
142142
shouldDoPublicRelease: sinon.stub().returns(Promise.resolve(true))
143143
});
@@ -158,7 +158,7 @@ describe('buildAndRelease', () => {
158158
expect(barque.releaseToBarque).to.have.been.called;
159159
});
160160

161-
it('does not releases to barque if not a public release', async () => {
161+
it('does not releases to barque if not a public release', async() => {
162162
githubRepo = createStubRepo({
163163
shouldDoPublicRelease: sinon.stub().resolves(false)
164164
});
@@ -179,7 +179,7 @@ describe('buildAndRelease', () => {
179179
expect(barque.releaseToBarque).to.not.have.been.called;
180180
});
181181

182-
it('releases to downloads centre if a public release', async () => {
182+
it('releases to downloads centre if a public release', async() => {
183183
githubRepo = createStubRepo({
184184
shouldDoPublicRelease: sinon.stub().resolves(true),
185185
releaseToGithub: sinon.stub().resolves(true)
@@ -201,7 +201,7 @@ describe('buildAndRelease', () => {
201201
expect(githubRepo.releaseToGithub).to.have.been.calledWith(tarballFile, config);
202202
});
203203

204-
it('does not release to downloads centre if not a public release', async () => {
204+
it('does not release to downloads centre if not a public release', async() => {
205205
githubRepo = createStubRepo({
206206
shouldDoPublicRelease: sinon.stub().resolves(false),
207207
releaseToGithub: sinon.stub().resolves(true)

packages/build/src/build-and-upload.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export default async function buildAndUpload(
1212
compileAndZipExecutable: (Config) => Promise<TarballFile>,
1313
uploadToEvergreen: (artifact: string, awsKey: string, awsSecret: string, project: string, revision: string) => Promise<void>,
1414
uploadToDownloadCenter: (artifact: string, awsKey: string, awsSecret: string) => Promise<void>): Promise<void> {
15-
console.log(
15+
console.info(
1616
'mongosh: beginning release with config:',
1717
redactConfig(config)
1818
);
1919

2020
// Build the executable.
2121
const tarballFile = await compileAndZipExecutable(config);
22-
console.log('mongosh: created tarball:', tarballFile);
22+
console.info('mongosh: created tarball:', tarballFile);
2323

2424
if (config.dryRun) return;
2525

@@ -31,13 +31,13 @@ export default async function buildAndUpload(
3131
config.project,
3232
config.revision
3333
);
34-
console.log('mongosh: internal release completed.');
34+
console.info('mongosh: internal release completed.');
3535

3636
const evergreenTarball = getArtifactUrl(config.project, config.revision, tarballFile.path);
3737

3838
// Only release to public from master and when tagged with the right version.
3939
if (await githubRepo.shouldDoPublicRelease(config)) {
40-
console.log('mongosh: start public release.');
40+
console.info('mongosh: start public release.');
4141

4242
await uploadToDownloadCenter(
4343
tarballFile.path,
@@ -46,11 +46,11 @@ export default async function buildAndUpload(
4646
);
4747

4848
await barque.releaseToBarque(evergreenTarball);
49-
console.log('mongosh: submitting to barque complete');
49+
console.info('mongosh: submitting to barque complete');
5050

5151
await githubRepo.releaseToGithub(tarballFile, config);
5252
}
5353

54-
console.log('mongosh: finished release process.');
54+
console.info('mongosh: finished release process.');
5555
}
5656

packages/build/src/compile-and-zip-executable.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export default async function compileAndZipExecutable(config: Config): Promise<T
2929
// step.
3030
if (os.platform() === Platform.MacOs && !config.dryRun) {
3131
return await macOSSignAndNotarize(executable, config, runCreateTarball);
32-
} else {
33-
return await runCreateTarball();
3432
}
33+
return await runCreateTarball();
3534
}

0 commit comments

Comments
 (0)