Skip to content

Commit f4ad160

Browse files
committed
feat: make crypto default
1 parent f05f37e commit f4ad160

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

.github/scripts/libmongocrypt.mjs

Lines changed: 16 additions & 16 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
@@ -142,7 +141,7 @@ export async function buildLibMongoCrypt(libmongocryptRoot, nodeDepsRoot, option
142141
});
143142
}
144143

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

232231
async function main() {
233-
const { libmongocrypt, build, clean, fastDownload } = await parseArguments();
232+
const args = await parseArguments();
233+
console.log(args);
234234

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

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

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

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

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

256-
if (clean || !isBuilt) {
257-
await buildLibMongoCrypt(libmongocryptCloneDir, nodeDepsDir, libmongocrypt);
256+
if (args.clean || !isBuilt) {
257+
await buildLibMongoCrypt(libmongocryptCloneDir, nodeDepsDir, args);
258258
}
259259
} else {
260260
// Download
261-
await downloadLibMongoCrypt(nodeDepsDir, libmongocrypt, fastDownload);
261+
await downloadLibMongoCrypt(nodeDepsDir, args);
262262
}
263263

264264
await fs.rm(resolveRoot('build'), { force: true, recursive: true });

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
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 }}
@@ -90,11 +90,11 @@ jobs:
9090
uses: ./.github/actions/setup
9191
- name: actions/sign_and_upload_package
9292
uses: ./.github/actions/sign_and_upload_package
93-
with:
93+
with:
9494
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
9595
aws_region_name: 'us-east-1'
9696
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
9797
npm_package_name: 'mongodb-client-encryption'
9898
- run: npm publish --provenance
9999
env:
100-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.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)