-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the first stage of converting the entire codebase over to TypeScript. The goals of this step were to preserve history as well as functional output of the compilation step. Here is a summary of the commits involved: - move all files to `src`, preserving history this also maintains a copy of the original js source in the `lib` folder (without history) so we can compare the transpiled output for potential issues - add type information to all types - move entry point `bson.ts` to `src` folder for ease of future testing - run tests against transpiled module code - fix all linting issues with ts conversion - fix running manual tests with ts codebase - ensure we run the ts pipeline before publish - bump typescript version, fix last outstanding issue - `prepublishOnly` => `prepare` NODE-2716 NODE-2718 NODE-2719 NODE-2721
- Loading branch information
Showing
74 changed files
with
6,094 additions
and
6,365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
docs/ | ||
types/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:prettier/recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint" | ||
], | ||
"env": { | ||
"node": true | ||
}, | ||
"globals": { | ||
"Promise": true, | ||
"Uint8Array": true, | ||
"ArrayBuffer": true, | ||
"Set": true, | ||
"Map": false | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2017 | ||
}, | ||
"plugins": [ | ||
"prettier" | ||
], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"no-console": "off", | ||
"eqeqeq": [ | ||
"error", | ||
"always", | ||
{ | ||
"null": "ignore" | ||
} | ||
], | ||
"strict": [ | ||
"error", | ||
"global" | ||
], | ||
"@typescript-eslint/ban-types": "off", | ||
"@typescript-eslint/no-var-requires": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
export PROJECT_DIRECTORY="$(pwd)" | ||
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts" | ||
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extension": [ | ||
"js" | ||
], | ||
"require": [ | ||
"ts-node/register", | ||
"chai/register-expect", | ||
"source-map-support/register" | ||
], | ||
"timeout": 10000, | ||
"throw-deprecation": true, | ||
"parallel": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "@istanbuljs/nyc-config-typescript", | ||
"include": ["src/**/*.ts"], | ||
"reporter": ["lcovonly", "text-summary"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"printWidth": 100, | ||
"arrowParens": "avoid", | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"mainEntryPointFilePath": "<projectFolder>/lib/bson.d.ts", | ||
"apiReport": { | ||
"enabled": false | ||
}, | ||
"docModel": { | ||
"enabled": false | ||
}, | ||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "<projectFolder>/<unscopedPackageName>.d.ts" | ||
}, | ||
"tsdocMetadata": { | ||
"enabled": false | ||
}, | ||
"newlineKind": "lf", | ||
"messages": { | ||
"compilerMessageReporting": { | ||
"default": { | ||
"logLevel": "error" | ||
} | ||
}, | ||
"extractorMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
}, | ||
"ae-internal-missing-underscore": { | ||
"logLevel": "none", | ||
"addToApiReportFile": false | ||
}, | ||
"ae-missing-release-tag": { | ||
"logLevel": "none", | ||
"addToApiReportFile": false | ||
}, | ||
"ae-incompatible-release-tags": { | ||
"logLevel": "none", | ||
"addToApiReportFile": false | ||
}, | ||
"ae-unresolved-link": { | ||
"addToApiReportFile": false, | ||
"logLevel": "none" | ||
} | ||
}, | ||
"tsdocMessageReporting": { | ||
"default": { | ||
"logLevel": "none" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
{ | ||
"name": "bson", | ||
"description": "A bson parser for node.js and the browser", | ||
"keywords": [ | ||
"mongodb", | ||
"bson", | ||
"parser" | ||
], | ||
"keywords": ["mongodb", "bson", "parser"], | ||
"author": "Christian Amor Kvalheim <[email protected]>", | ||
"main": "./dist/bson.js", | ||
"license": "Apache-2.0", | ||
"moduleType": [ | ||
"globals", | ||
"node" | ||
], | ||
"moduleType": ["globals", "node"], | ||
"ignore": [ | ||
"**/.*", | ||
"alternate_parsers", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env node | ||
var cp = require('child_process'); | ||
var fs = require('fs'); | ||
|
||
var nodeMajorVersion = +process.version.match(/^v(\d+)\.\d+/)[1]; | ||
|
||
if (fs.existsSync('src') && nodeMajorVersion >= 10) { | ||
cp.spawnSync('npm', ['run', 'build'], { stdio: 'inherit', shell: true }); | ||
} else { | ||
if (!fs.existsSync('lib')) { | ||
console.warn('BSON: No compiled javascript present, the library is not installed correctly.'); | ||
if (nodeMajorVersion < 10) { | ||
console.warn( | ||
'This library can only be compiled in nodejs version 10 or later, currently running: ' + | ||
nodeMajorVersion | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.