Skip to content

Commit

Permalink
fix(deps): bulk add missing dependencies - 2023-11-02
Browse files Browse the repository at this point in the history
1. Added missing dependencies everywhere to all the packages
2. The exception to the above is test runners and related dependencies.
You can see the detailed exclusion list in the source code of the script
itself [1]. We should make these configurable later on as well. For
reference, this is what the exclusions were declared as when I ran the
tool in order to then proceed to update the package.json files:

```typescript
ignorePatterns: [
    // files matching these patterns will be ignored
    "sandbox",
    "dist",
    "bower_components",
    "node_modules"
],
ignoreMatches: [
    // ignore dependencies that matches these globs
    "grunt-*",
    "jest-extended",
    "tape-promise",
    "tape",
    "tap",
    "@ionic-native/*"
],
```
3. There were instances of missing dependency usages where we did NOT
have to add the dependencies to package.json files because what we could
do instead is just import types at development time by using the
`import type { .. } from "...";`  syntax of Typescript which means that
the import is disappeared during transpilation completely. So this is why
some source code files were also modified and not strictly just package.json
files.
4. One exception to the above is the google-sm-keychain plugin's mock
code where minimal code alternations were necessary to satisfy the compiler.
With that said, no behavioral code change was done here either, just the
elimination of some redundant assignments.
5. Added a script in the ./tools/custom-check directory to audit the
entire mono-repo for missing NodeJS dependencies.

We've had at least a dozen packages that were missing production
dependency declarations from their package.json files. The usual suspects
here are packages that are contained by the root node_modules folder
which masks the problem at development time (e.g. the compiler won't
let you know about the missing dependencies).

For a future-proof solution we should add a commit hook or other validation
that runs the custom check that I added [2] here to verify that there are no
missing dependencies in the project

[1] `./tools/custom-checks/check-missing-node-deps.ts`
[2] `$ yarn tools:check-missing-node-deps`

Fixes #2857

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Nov 14, 2023
1 parent 36d5e1d commit 8addb01
Show file tree
Hide file tree
Showing 87 changed files with 1,423 additions and 111 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"KEYUTIL",
"KJUR",
"Knetic",
"kubo",
"LEDGERBLOCKACK",
"leveldb",
"lmify",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Request } from "express";
import type { Request } from "express";
import { getLogger } from "log4js";
import { RequestInfo } from "./RequestInfo";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
},
"dependencies": {
"escape-html": "1.0.3",
"express": "4.18.2",
"js-yaml": "4.1.0",
"log4js": "6.9.1",
"shelljs": "0.8.5",
"socket.io": "4.5.4"
},
"devDependencies": {
"@hyperledger/cactus-common": "2.0.0-alpha.2",
"@types/escape-html": "1.0.1",
"@types/node": "15.14.9"
"@types/express": "4.17.20",
"@types/js-yaml": "4.0.8",
"@types/node": "15.14.9",
"@types/shelljs": "0.8.14"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
BESU_DEMO_LEDGER_ID,
CACTUS_API_URL,
FABRIC_DEMO_LEDGER_ID,
} from "src/constants";
} from "../constants";
import { ApiClient } from "@hyperledger/cactus-api-client";

LoggerProvider.setLogLevel("TRACE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
} from "./fabric-connector";
import { sendEthereumTransaction } from "./transaction-ethereum";
import { hasKey } from "@hyperledger/cactus-common";
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";

const moduleName = "BusinessLogicAssetTrade";
const logger = getLogger(`${moduleName}`);
Expand Down
7 changes: 6 additions & 1 deletion examples/cactus-example-discounted-asset-trade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@
"fabric-ca-client": "2.2.19",
"fabric-network": "2.2.19",
"http-errors": "1.6.3",
"indy-sdk": "1.16.0-dev-1655",
"jsonwebtoken": "9.0.0",
"jsrsasign": "10.5.25",
"log4js": "6.4.0",
"morgan": "1.9.1",
"run-time-error-cjs": "1.4.0",
"shelljs": "0.8.5",
"socket.io": "4.5.4",
"ts-node": "8.9.1",
"uuid": "9.0.1",
"xmlhttprequest": "1.8.0"
},
"devDependencies": {
"@types/elliptic": "6.4.14",
"@types/escape-html": "1.0.1",
"@types/express": "4.17.19",
"@types/indy-sdk": "1.16.29",
"@types/jsonwebtoken": "9.0.2",
"@types/jsrsasign": "10.5.8"
"@types/jsrsasign": "10.5.8",
"@types/uuid": "9.0.6"
}
}
2 changes: 2 additions & 0 deletions examples/cactus-example-electricity-trade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
"shelljs": "0.8.5",
"socket.io": "4.5.4",
"ts-node": "8.9.1",
"uuid": "9.0.1",
"web3": "1.8.1",
"xmlhttprequest": "1.8.0"
},
"devDependencies": {
"@types/escape-html": "1.0.1",
"@types/express": "4.17.19",
"@types/uuid": "9.0.6",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"eslint": "7.32.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"axios": "1.5.1",
"express": "4.18.2",
"openapi-types": "9.1.0",
"run-time-error-cjs": "1.4.0",
"typescript-optional": "2.0.1",
"uuid": "8.3.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BambooHarvest } from "../../generated/openapi/typescript-axios";
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";

/**
* Responsible for converting model entities such as the `BambooHarvest` to and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Bookshelf } from "../../generated/openapi/typescript-axios/index";
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";

/**
* Responsible for converting model entities such as the `Bookshelf` to and
Expand Down
3 changes: 3 additions & 0 deletions examples/cactus-example-supply-chain-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@
"@ionic-native/status-bar": "5.36.0",
"@ionic/angular": "7.3.3",
"net-browserify": "0.2.4",
"run-time-error-cjs": "1.4.0",
"rxjs": "7.8.1",
"tls-browserify": "0.2.2",
"tslib": "2.6.2",
"uuid": "9.0.1",
"zone.js": "0.13.1"
},
"devDependencies": {
Expand All @@ -80,6 +82,7 @@
"@angular/compiler-cli": "16.2.4",
"@angular/language-service": "16.2.4",
"@ionic/angular-toolkit": "10.0.0",
"@types/uuid": "9.0.6",
"browserify-fs": "1.0.0",
"https-browserify": "1.0.0",
"net-browserify": "0.2.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
CACTUS_API_URL,
QUORUM_DEMO_LEDGER_ID,
FABRIC_DEMO_LEDGER_ID,
} from "src/constants";
} from "../constants";
import { ApiClient } from "@hyperledger/cactus-api-client";
import { AuthConfig } from "./common/auth-config";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuidv4 } from "uuid";
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";

import { Component, Inject, Input, OnInit } from "@angular/core";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "@hyperledger/cactus-example-supply-chain-business-logic-plugin";

import { Logger, LoggerProvider } from "@hyperledger/cactus-common";
import { QUORUM_DEMO_LEDGER_ID } from "src/constants";
import { QUORUM_DEMO_LEDGER_ID } from "../../../constants";

import { AuthConfig } from "../../common/auth-config";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "@hyperledger/cactus-example-supply-chain-business-logic-plugin";

import { Logger, LoggerProvider } from "@hyperledger/cactus-common";
import { QUORUM_DEMO_LEDGER_ID } from "src/constants";
import { QUORUM_DEMO_LEDGER_ID } from "../../../constants";

import { AuthConfig } from "../../common/auth-config";

Expand Down
2 changes: 2 additions & 0 deletions examples/cactus-example-tcs-huawei/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"@hyperledger/cactus-verifier-client": "2.0.0-alpha.2",
"@types/node": "14.18.54",
"@types/uuid": "9.0.6",
"body-parser": "1.20.2",
"cookie-parser": "1.4.6",
"debug": "2.6.9",
Expand All @@ -33,6 +34,7 @@
"shelljs": "0.8.5",
"socket.io": "4.5.4",
"ts-node": "8.9.1",
"uuid": "9.0.1",
"web3": "1.7.0",
"xmlhttprequest": "1.8.0"
},
Expand Down
9 changes: 8 additions & 1 deletion examples/cactus-workshop-examples-2022-11-14/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
},
"dependencies": {
"@hyperledger/cactus-cmd-api-server": "2.0.0-alpha.2",
"@hyperledger/cactus-common": "2.0.0-alpha.2",
"@hyperledger/cactus-core": "2.0.0-alpha.2",
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"typescript-optional": "2.0.1"
"kubo-rpc-client": "3.0.1",
"typescript-optional": "2.0.1",
"uuid": "9.0.1"
},
"devDependencies": {
"@types/uuid": "9.0.6"
},
"engines": {
"node": ">=10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { ApiServer, ConfigService } from "@hyperledger/cactus-cmd-api-server";
import { Logger, LoggerProvider } from "@hyperledger/cactus-common";
import { GoIpfsTestContainer } from "@hyperledger/cactus-test-tooling";
import { create } from "ipfs-http-client";
import { createServer } from "http";
import { v4 as uuidv4 } from "uuid";
import {
Expand All @@ -23,6 +22,7 @@ const main = async () => {
// retrieve the url so that the IPFS connector plugin is
// able to connect to the IPFS network. This will be used
// as an argument for the plugin bellow
const { create } = await import("kubo-rpc-client");
const ipfsClientOrOptions = create({
url: await ipfsNetwork.getApiUrl(),
});
Expand Down
4 changes: 3 additions & 1 deletion extensions/cactus-plugin-htlc-coordinator-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@
"prom-client": "13.1.0",
"run-time-error": "1.4.0",
"socket.io-client": "4.5.4",
"typescript-optional": "2.0.1"
"typescript-optional": "2.0.1",
"uuid": "9.0.1"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0-alpha.2",
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@types/express": "4.17.19",
"@types/uuid": "9.0.6",
"express": "4.18.2",
"socket.io": "4.5.4",
"web3-eth-abi": "4.0.3",
Expand Down
2 changes: 2 additions & 0 deletions extensions/cactus-plugin-object-store-ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
},
"devDependencies": {
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@types/body-parser": "1.19.4",
"@types/express": "4.17.19",
"body-parser": "1.20.2",
"express": "4.18.2",
"ipfs-core-types": "0.14.1",
"multiformats": "9.4.9"
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"tools:generate-sbom": "TS_NODE_PROJECT=tools/tsconfig.json node --experimental-json-modules --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/generate-sbom.ts",
"tools:fix-pkg-npm-scope": "TS_NODE_PROJECT=tools/tsconfig.json node --experimental-json-modules --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/custom-checks/check-pkg-npm-scope.ts",
"tools:sort-package-json": "TS_NODE_PROJECT=tools/tsconfig.json node --experimental-json-modules --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/sort-package-json.ts",
"tools:check-missing-node-deps": "TS_NODE_PROJECT=tools/tsconfig.json node --experimental-json-modules --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/custom-checks/check-missing-node-deps.ts",
"generate-api-server-config": "node ./tools/generate-api-server-config.js",
"sync-ts-config": "TS_NODE_PROJECT=tools/tsconfig.json node --experimental-json-modules --loader ts-node/esm ./tools/sync-npm-deps-to-tsc-projects.ts",
"start:api-server": "node ./packages/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js --config-file=.config.json",
Expand Down Expand Up @@ -117,6 +118,7 @@
"cspell": "5.21.2",
"del": "7.1.0",
"del-cli": "4.0.1",
"depcheck": "1.4.7",
"es-main": "1.2.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.10.0",
Expand Down Expand Up @@ -211,6 +213,9 @@
"esbuild": {
"built": false
},
"indy-sdk": {
"built": false
},
"iso-constants": {
"built": false
},
Expand Down
1 change: 1 addition & 0 deletions packages/cactus-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"key-encoder": "2.0.3",
"loglevel": "1.7.1",
"loglevel-plugin-prefix": "0.8.4",
"run-time-error-cjs": "1.4.0",
"sanitize-html": "2.7.0",
"secp256k1": "4.0.3",
"sha3": "2.1.4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";
import { coerceUnknownToError } from "./coerce-unknown-to-error";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "jest-extended";

import { createRuntimeErrorWithCause } from "../../../../main/typescript/public-api";
import stringify from "fast-safe-stringify";
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";

describe("createRuntimeErrorWithCause() & newRex()", () => {
it("avoids losing information of inner exception: RuntimeError instance", () => {
Expand Down
1 change: 1 addition & 0 deletions packages/cactus-core-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@grpc/proto-loader": "0.7.8",
"@types/express": "4.17.19",
"@types/google-protobuf": "3.15.5",
"google-protobuf": "3.21.2",
"grpc-tools": "1.12.4",
"grpc_tools_node_protoc_ts": "5.3.3",
"make-dir-cli": "3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Express } from "express";
import type { Express } from "express";
import { IAsyncProvider } from "@hyperledger/cactus-common";
import { IEndpointAuthzOptions } from "./i-endpoint-authz-options";
import { IExpressRequestHandler } from "./i-express-request-handler";
Expand Down
1 change: 1 addition & 0 deletions packages/cactus-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"express": "4.18.2",
"express-jwt-authz": "2.4.1",
"express-openapi-validator": "5.0.4",
"run-time-error-cjs": "1.4.0",
"safe-stable-stringify": "2.4.3",
"typescript-optional": "2.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Express, Request, Response } from "express";
import { RuntimeError } from "run-time-error";
import { RuntimeError } from "run-time-error-cjs";
import { stringify } from "safe-stable-stringify";

import {
Expand Down
6 changes: 5 additions & 1 deletion packages/cactus-plugin-keychain-aws-sm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@
},
"devDependencies": {
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@types/body-parser": "1.19.4",
"@types/express": "4.17.19",
"@types/request": "2.48.7",
"@types/uuid": "9.0.6",
"body-parser": "1.20.2",
"express": "4.18.2",
"internal-ip": "6.2.0",
"openapi-types": "9.1.0"
"openapi-types": "9.1.0",
"uuid": "9.0.1"
},
"engines": {
"node": ">=10",
Expand Down
5 changes: 4 additions & 1 deletion packages/cactus-plugin-keychain-azure-kv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@
},
"devDependencies": {
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@types/body-parser": "1.19.4",
"@types/express": "4.17.19",
"@types/request": "2.48.7",
"body-parser": "1.20.2",
"express": "4.18.2",
"internal-ip": "6.2.0",
"openapi-types": "9.1.0"
"openapi-types": "9.1.0",
"uuid": "9.0.1"
},
"engines": {
"node": ">=10",
Expand Down
7 changes: 6 additions & 1 deletion packages/cactus-plugin-keychain-google-sm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@
"@hyperledger/cactus-core-api": "2.0.0-alpha.2",
"axios": "1.5.1",
"http-status-codes": "2.1.4",
"typescript-optional": "2.0.1"
"typescript-optional": "2.0.1",
"uuid": "9.0.1"
},
"devDependencies": {
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.2",
"@types/body-parser": "1.19.4",
"@types/express": "4.17.19",
"@types/request": "2.48.7",
"@types/uuid": "9.0.6",
"body-parser": "1.20.2",
"express": "4.18.2",
"google-gax": "4.0.5",
"internal-ip": "6.2.0",
"openapi-types": "9.1.0"
},
Expand Down
Loading

0 comments on commit 8addb01

Please sign in to comment.