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
45 changes: 45 additions & 0 deletions .github/scripts/lint-pkg.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @ts-check
import fs from "node:fs";

// Find every package.json in this repo that is not in node_modules and not in .github
// and run local us-en sort on the dependencies, devDependencies and peerDependencies.
// assert that there's no changes.

const collator = new Intl.Collator("en-US");

/** @param {string[]} keys */
function isSorted(keys) {
const sorted = keys.toSorted(collator.compare);
return keys.every((key, index) => key === sorted[index]);
}

/** @type {string[]} */
const packageJsonPaths = [];
for await (const path of fs.promises.glob("**/package.json")) {
if (!path.includes("node_modules/") && !path.startsWith(".github/")) {
packageJsonPaths.push(path);
}
}

Comment thread
nbbeeken marked this conversation as resolved.
const results = await Promise.all(
packageJsonPaths.map(async (path) => {
const pkg = JSON.parse(await fs.promises.readFile(path, "utf8"));
return ["dependencies", "devDependencies", "peerDependencies"]
.filter((field) => pkg[field] && !isSorted(Object.keys(pkg[field])))
.map((field) => `${path} (${field})`);
}),
);

const unsorted = results.flat();

if (unsorted.length > 0) {
console.error(
"Error: The following package.json files have unsorted dependencies:\n" +
unsorted.map((entry) => ` - ${entry}`).join("\n"),
);
process.exitCode = 1;
} else {
console.log(
`Success: Checked ${packageJsonPaths.length} package.json files, all dependencies are sorted.`,
);
}
20 changes: 19 additions & 1 deletion .github/workflows/check-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:

- name: Run Tests
run: |
scopes=$(node .github/workflows/compute-test-group.mjs "${{ matrix.group }}" "${TOTAL_GROUPS}")
scopes=$(node .github/scripts/compute-test-group.mjs "${{ matrix.group }}" "${TOTAL_GROUPS}")
echo "Testing group ${{ matrix.group }}/${TOTAL_GROUPS} with: ${scopes}"
npm run test-ci -- --stream ${scopes}
shell: bash
Expand Down Expand Up @@ -143,3 +143,21 @@ jobs:
COVERALLS_GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
COVERALLS_REPO_TOKEN: ${{ github.token }}
COVERALLS_GIT_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
Comment thread
nbbeeken marked this conversation as resolved.
with:
fetch-depth: 0
submodules: recursive

- name: Setup Node.js
uses: actions/setup-node@v6
Comment thread
nbbeeken marked this conversation as resolved.
with:
node-version: 22.21.1

- name: Run Lint
run: node .github/scripts/lint-pkg.mjs
2 changes: 1 addition & 1 deletion configs/eslint-config-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"homepage": "https://github.com/mongodb-js/devtools-shared",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion configs/eslint-plugin-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.3.4",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"index.js",
Expand Down
2 changes: 1 addition & 1 deletion configs/mocha-config-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"homepage": "https://github.com/mongodb-js/devtools-shared",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion configs/prettier-config-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"homepage": "https://github.com/mongodb-js/devtools-shared",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion configs/tsconfig-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"homepage": "https://github.com/mongodb-js/devtools",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/aggregation-stage-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.2.14",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/device-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.4.13",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage": "https://github.com/mongodb-js/devtools-shared/tree/main/packages/devtools-connect",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 3 additions & 3 deletions packages/devtools-proxy-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.7.17",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down Expand Up @@ -67,11 +67,11 @@
"@mongodb-js/socksv5": "^0.0.10",
"agent-base": "^7.1.1",
"debug": "^4.4.0",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5",
"lru-cache": "^11.3.5",
"node-fetch": "^3.3.2",
"pac-proxy-agent": "^7.0.2",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.5",
"socks-proxy-agent": "^8.0.4",
"ssh2": "^1.17.0",
"system-ca": "^3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/dl-center/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "1.6.13",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down Expand Up @@ -63,11 +63,11 @@
"@types/node": "^25.5.2",
"@types/s3rver": "^3.7.4",
"@types/sinon-chai": "^4.0.0",
"json-schema-to-typescript": "^13.0.2",
"chai": "^4.5.0",
"depcheck": "^1.4.7",
"eslint": "^7.25.0 || ^8.0.0",
"gen-esm-wrapper": "^1.1.3",
"json-schema-to-typescript": "^13.0.2",
"mocha": "^8.4.0",
"nock": "^14.0.12",
"nyc": "^15.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/download-url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
"nyc": "^15.1.0",
"prettier": "^3.8.1",
"sinon": "^9.2.3",
"typescript": "^5.9.3",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
},
"keywords": [
"mongodb",
"mongodb.js"
],
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"author": "Lucas Hrabovsky <hrabovsky.lucas@gmail.com> (http://imlucas.com)",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/get-os-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.7.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-build-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"homepage": "https://github.com/mongodb-js/devtools-shared",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git",
"url": "git+https://github.com/mongodb-js/devtools-shared.git",
"directory": "packages/mongodb-build-info"
},
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-cloud-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"homepage": "https://github.com/mongodb-js/devtools-shared",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.34.2",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
8 changes: 4 additions & 4 deletions packages/mongodb-downloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "1.1.16",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down Expand Up @@ -53,18 +53,18 @@
},
"dependencies": {
"debug": "^4.4.0",
"tar": "^7.5.11",
"decompress": "^4.2.1",
"mongodb-download-url": "^1.8.14",
"node-fetch": "^2.7.0",
"proper-lockfile": "^4.1.2"
"proper-lockfile": "^4.1.2",
"tar": "^7.5.11"
},
"devDependencies": {
"@mongodb-js/eslint-config-devtools": "^0.11.7",
"@mongodb-js/mocha-config-devtools": "^1.1.2",
"@mongodb-js/prettier-config-devtools": "^1.0.3",
"@types/chai": "^4.2.21",
"@mongodb-js/tsconfig-devtools": "^1.1.2",
"@types/chai": "^4.2.21",
"@types/debug": "^4.1.8",
"@types/decompress": "^4.2.7",
"@types/mocha": "^9.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-log-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"homepage": "https://github.com/mongodb-js/devtools-shared",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"keywords": [
"mongodb",
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-ns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "3.2.0",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
6 changes: 3 additions & 3 deletions packages/mongodb-redact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "1.4.11",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down Expand Up @@ -71,7 +71,7 @@
"typescript": "^5.9.3"
},
"dependencies": {
"regexp.escape": "^2.0.1",
"mongodb-connection-string-url": "^3.0.1 || ^7.0.0"
"mongodb-connection-string-url": "^3.0.1 || ^7.0.0",
"regexp.escape": "^2.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/mongodb-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "6.8.4",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-server-log-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.2.17",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/mongodb-ts-autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.8.1",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist"
Expand Down
14 changes: 7 additions & 7 deletions packages/monorepo-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": "1.5.7",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"license": "SSPL",
"files": [
Expand All @@ -23,12 +23,12 @@
],
"main": "dist/index.js",
"bin": {
"precommit": "./bin/precommit.js",
"depalign": "./bin/depalign.js",
"monorepo-where": "./bin/where.js",
"bump-monorepo-packages": "./bin/bump-packages.js",
"request-npm-token": "./bin/request-npm-token.js",
"check-transitive-deps": "./bin/check-transitive-deps.js"
"precommit": "bin/precommit.js",
"depalign": "bin/depalign.js",
"monorepo-where": "bin/where.js",
"bump-monorepo-packages": "bin/bump-packages.js",
"request-npm-token": "bin/request-npm-token.js",
"check-transitive-deps": "bin/check-transitive-deps.js"
},
"scripts": {
"bootstrap": "npm run compile",
Expand Down
2 changes: 1 addition & 1 deletion packages/mql-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": "0.6.1",
"repository": {
"type": "git",
"url": "https://github.com/mongodb-js/devtools-shared.git"
"url": "git+https://github.com/mongodb-js/devtools-shared.git"
},
"files": [
"dist",
Expand Down
Loading
Loading