Skip to content

Commit ba7fea7

Browse files
committed
feat: make crypto default
1 parent 1a5d641 commit ba7fea7

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

.github/scripts/libmongocrypt.mjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
import util from 'node:util';
23
import process from 'node:process';
34
import fs from 'node:fs/promises';
@@ -23,7 +24,7 @@ async function parseArguments() {
2324
libVersion: { short: 'l', type: 'string', default: pkg['mongodb:libmongocrypt'] },
2425
clean: { short: 'c', type: 'boolean', default: false },
2526
build: { short: 'b', type: 'boolean', default: false },
26-
crypto: { type: 'boolean', default: false }, // Use Node.js builtin crypto
27+
'no-crypto': { type: 'boolean', default: false }, // Use Node.js builtin crypto
2728
fastDownload: { type: 'boolean', default: false }, // Potentially incorrect download, only for the brave and impatient
2829
help: { short: 'h', type: 'boolean', default: false }
2930
};
@@ -41,11 +42,9 @@ async function parseArguments() {
4142
}
4243

4344
return {
44-
libmongocrypt: {
45-
url: args.values.gitURL,
46-
ref: args.values.libVersion,
47-
crypto: args.values.crypto
48-
},
45+
url: args.values.gitURL,
46+
ref: args.values.libVersion,
47+
crypto: !args.values['no-crypto'],
4948
fastDownload: args.values.fastDownload,
5049
clean: args.values.clean,
5150
build: args.values.build,
@@ -143,7 +142,7 @@ export async function buildLibMongoCrypt(libmongocryptRoot, nodeDepsRoot, option
143142
});
144143
}
145144

146-
export async function downloadLibMongoCrypt(nodeDepsRoot, { ref, crypto }, fastDownload) {
145+
export async function downloadLibMongoCrypt(nodeDepsRoot, { ref, crypto, fastDownload }) {
147146
const downloadURL =
148147
ref === 'latest'
149148
? 'https://mciuploads.s3.amazonaws.com/libmongocrypt/all/master/latest/libmongocrypt-all.tar.gz'
@@ -231,35 +230,36 @@ export async function downloadLibMongoCrypt(nodeDepsRoot, { ref, crypto }, fastD
231230
}
232231

233232
async function main() {
234-
const { libmongocrypt, build, clean, pkg } = await parseArguments();
233+
const args = await parseArguments();
234+
console.log(args);
235235

236236
const nodeDepsDir = resolveRoot('deps');
237237

238-
if (build) {
238+
if (args.build) {
239239
const libmongocryptCloneDir = resolveRoot('_libmongocrypt');
240240

241241
const currentLibMongoCryptBranch = await fs
242242
.readFile(path.join(libmongocryptCloneDir, '.git', 'HEAD'), 'utf8')
243243
.catch(() => '');
244244
const isClonedAndCheckedOut = currentLibMongoCryptBranch
245245
.trim()
246-
.endsWith(`r-${libmongocrypt.ref}`);
246+
.endsWith(`r-${args.ref}`);
247247

248-
if (clean || !isClonedAndCheckedOut) {
249-
await cloneLibMongoCrypt(libmongocryptCloneDir, libmongocrypt);
248+
if (args.clean || !isClonedAndCheckedOut) {
249+
await cloneLibMongoCrypt(libmongocryptCloneDir, args);
250250
}
251251

252252
const libmongocryptBuiltVersion = await fs
253253
.readFile(path.join(libmongocryptCloneDir, 'VERSION_CURRENT'), 'utf8')
254254
.catch(() => '');
255-
const isBuilt = libmongocryptBuiltVersion.trim() === libmongocrypt.ref;
255+
const isBuilt = libmongocryptBuiltVersion.trim() === args.ref;
256256

257-
if (clean || !isBuilt) {
258-
await buildLibMongoCrypt(libmongocryptCloneDir, nodeDepsDir, libmongocrypt);
257+
if (args.clean || !isBuilt) {
258+
await buildLibMongoCrypt(libmongocryptCloneDir, nodeDepsDir, args);
259259
}
260260
} else {
261261
// Download
262-
await downloadLibMongoCrypt(nodeDepsDir, libmongocrypt, fastDownload);
262+
await downloadLibMongoCrypt(nodeDepsDir, args);
263263
}
264264

265265
await fs.rm(resolveRoot('build'), { force: true, recursive: true });
@@ -274,8 +274,8 @@ async function main() {
274274
if (process.platform === 'darwin') {
275275
// The "arm64" build is actually a universal binary
276276
await fs.copyFile(
277-
resolveRoot('prebuilds', `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-arm64.tar.gz`),
278-
resolveRoot('prebuilds', `mongodb-client-encryption-v${pkg.version}-napi-v4-darwin-x64.tar.gz`)
277+
resolveRoot('prebuilds', `mongodb-client-encryption-v${args.pkg.version}-napi-v4-darwin-arm64.tar.gz`),
278+
resolveRoot('prebuilds', `mongodb-client-encryption-v${args.pkg.version}-napi-v4-darwin-x64.tar.gz`)
279279
);
280280
}
281281
}

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v4
2323

2424
- name: Build ${{ matrix.os }} Prebuild
25-
run: node .github/scripts/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }}
25+
run: npm run install:libmongocrypt ${{ runner.os == 'Windows' && '-- --build' || '' }}
2626
shell: bash
2727

2828
- name: Test ${{ matrix.os }}

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
- if: matrix.build-mode == 'manual'
4848
shell: bash
49-
run: node .github/scripts/libmongocrypt.mjs
49+
run: npm run install:libmongocrypt
5050

5151
- name: Perform CodeQL Analysis
5252
uses: github/codeql-action/analyze@v3

0 commit comments

Comments
 (0)