Skip to content

Commit

Permalink
fix: circular deps check in CI
Browse files Browse the repository at this point in the history
- remove `--summary` flag so exit codes are correct
- resolve all circular refs within packages
  • Loading branch information
Ivaylo Andonov committed Mar 24, 2023
1 parent d706a3d commit 070f5e9
Show file tree
Hide file tree
Showing 38 changed files with 105 additions and 107 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"build": "yarn workspaces foreach -v run build",
"circular-deps:check": "yarn workspaces foreach -v run circular-deps:check --summary",
"circular-deps:check": "yarn workspaces foreach -v run circular-deps:check",
"cleanup-build": "yarn workspaces foreach -v run cleanup && yarn install && yarn workspaces foreach -v run build",
"reinstall": "yarn workspaces foreach -v run cleanup:nm && yarn install",
"rebuild": "yarn workspaces foreach -v run cleanup:dist && yarn workspaces foreach -v run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/cardano-services-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"module-fixup": "shx cp ../../build/cjs-package.json ./dist/cjs/package.json && cp ../../build/esm-package.json ./dist/esm/package.json",
"tscNoEmit": "shx echo typescript --noEmit command not implemented yet",
"cleanup:dist": "shx rm -rf dist",
"circular-deps:check": "madge --circular dist",
"circular-deps:check": "madge --circular dist/cjs",
"cleanup:nm": "shx rm -rf node_modules",
"cleanup": "run-s cleanup:dist cleanup:nm",
"lint": "eslint -c ../../complete.eslintrc.js \"src/**/*.ts\" \"test/**/*.ts\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/cardano-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"cleanup": "run-s cleanup:dist cleanup:nm",
"cli": "ts-node --transpile-only src/cli.ts",
"coverage": "yarn test --coverage",
"circular-deps:check": "madge --circular dist",
"circular-deps:check": "madge --circular dist/cjs",
"lint": "eslint -c ../../complete.eslintrc.js \"src/**/*.ts\" \"test/**/*.ts\"",
"lint:fix": "yarn lint --fix",
"mainnet:dev": "DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -p cardano-services-mainnet -f docker-compose.yml -f docker-compose-dev.yml up",
Expand Down
2 changes: 1 addition & 1 deletion packages/cardano-services/src/Asset/AssetHttpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as OpenApiValidator from 'express-openapi-validator';
import { AssetProvider } from '@cardano-sdk/core';
import { HttpService } from '../Http';
import { Logger } from 'ts-log';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { providerHandler } from '../util';
import express from 'express';
import path from 'path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as OpenApiValidator from 'express-openapi-validator';
import { ChainHistoryProvider } from '@cardano-sdk/core';
import { HttpService } from '../Http';
import { Logger } from 'ts-log';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { providerHandler } from '../util';
import express from 'express';
import path from 'path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
createSlotEpochCalc
} from '@cardano-sdk/core';
import { DbSyncProvider, DbSyncProviderDependencies, Disposer, EpochMonitor } from '../../util';
import { GenesisData, InMemoryCache, UNLIMITED_CACHE_TTL } from '../..';
import { GenesisData } from '../../types';
import { InMemoryCache, UNLIMITED_CACHE_TTL } from '../../InMemoryCache';
import { Logger } from 'ts-log';
import { NetworkInfoBuilder } from './NetworkInfoBuilder';
import { RunnableModule } from '@cardano-sdk/util';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as OpenApiValidator from 'express-openapi-validator';
import { HttpService } from '../Http';
import { Logger } from 'ts-log';
import { NetworkInfoProvider } from '@cardano-sdk/core';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { providerHandler } from '../util';
import express from 'express';
import path from 'path';
Expand Down
2 changes: 1 addition & 1 deletion packages/cardano-services/src/Program/options/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command, Option } from 'commander';
import { InvalidLoggerLevel } from '../../errors';
import { LogLevel } from 'bunyan';
import { Programs } from '../programs';
import { Programs } from '../programs/types';
import {
SERVICE_DISCOVERY_BACKOFF_FACTOR_DEFAULT,
SERVICE_DISCOVERY_TIMEOUT_DEFAULT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BlockfrostWorker, BlockfrostWorkerConfig, getPool } from '../services';
import { CommonProgramOptions, PosgresProgramOptions, PostgresOptionDescriptions } from '../options';
import { Logger } from 'ts-log';
import { MissingProgramOption } from '..';
import { MissingProgramOption } from '../errors/MissingProgramOption';
import { SrvRecord } from 'dns';
import { createDnsResolver } from '../utils';
import { createLogger } from 'bunyan';
Expand Down
11 changes: 1 addition & 10 deletions packages/cardano-services/src/Program/programs/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
export * from './blockfrostWorker';
export * from './providerServer';
export * from './txWorker';

/**
* cardano-services programs
*/

export enum Programs {
BlockfrostWorker = 'Blockfrost worker',
ProviderServer = 'Provider server',
RabbitmqWorker = 'RabbitMQ worker'
}
export * from './types';
65 changes: 6 additions & 59 deletions packages/cardano-services/src/Program/programs/providerServer.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
/* eslint-disable complexity */
/* eslint-disable sonarjs/cognitive-complexity */
import {
AssetHttpService,
CardanoTokenRegistry,
DbSyncAssetProvider,
DbSyncNftMetadataService,
StubTokenMetadataService
} from '../../Asset';
import { AssetHttpService } from '../../Asset/AssetHttpService';
import { CardanoNode } from '@cardano-sdk/core';
import { CardanoTokenRegistry } from '../../Asset/CardanoTokenRegistry';
import { ChainHistoryHttpService, DbSyncChainHistoryProvider } from '../../ChainHistory';
import {
CommonProgramOptions,
OgmiosProgramOptions,
PosgresProgramOptions,
PostgresOptionDescriptions,
RabbitMqProgramOptions
} from '../options';
import { DbSyncAssetProvider } from '../../Asset/DbSyncAssetProvider';
import { DbSyncEpochPollService, loadGenesisData } from '../../util';
import { DbSyncNetworkInfoProvider, NetworkInfoHttpService } from '../../NetworkInfo';
import { DbSyncNftMetadataService, StubTokenMetadataService } from '../../Asset';
import { DbSyncRewardsProvider, RewardsHttpService } from '../../Rewards';
import { DbSyncStakePoolProvider, StakePoolHttpService, createHttpStakePoolMetadataService } from '../../StakePool';
import { DbSyncUtxoProvider, UtxoHttpService } from '../../Utxo';
Expand All @@ -28,6 +18,8 @@ import { InMemoryCache, NoCache } from '../../InMemoryCache';
import { Logger } from 'ts-log';
import { MissingProgramOption, MissingServiceDependency, RunnableDependencies, UnknownServiceName } from '../errors';
import { OgmiosCardanoNode } from '@cardano-sdk/ogmios';
import { PostgresOptionDescriptions } from '../options/postgres';
import { ProviderServerArgs, ProviderServerOptionDescriptions, ServiceNames } from './types';
import { SrvRecord } from 'dns';
import { TxSubmitHttpService } from '../../TxSubmit';
import { URL } from 'url';
Expand All @@ -45,20 +37,6 @@ export const PAGINATION_PAGE_SIZE_LIMIT_DEFAULT = 25;
export const USE_BLOCKFROST_DEFAULT = false;
export const USE_QUEUE_DEFAULT = false;

/**
* Used as mount segments, so must be URL-friendly
*
*/
export enum ServiceNames {
Asset = 'asset',
StakePool = 'stake-pool',
NetworkInfo = 'network-info',
TxSubmit = 'tx-submit',
Utxo = 'utxo',
ChainHistory = 'chain-history',
Rewards = 'rewards'
}

export const cardanoNodeDependantServices = new Set([
ServiceNames.NetworkInfo,
ServiceNames.StakePool,
Expand All @@ -68,37 +46,6 @@ export const cardanoNodeDependantServices = new Set([
ServiceNames.ChainHistory
]);

export enum ProviderServerOptionDescriptions {
CardanoNodeConfigPath = 'Cardano node config path',
DbCacheTtl = 'Cache TTL in seconds between 60 and 172800 (two days), an option for database related operations',
DisableDbCache = 'Disable DB cache',
DisableStakePoolMetricApy = 'Omit this metric for improved query performance',
EpochPollInterval = 'Epoch poll interval',
TokenMetadataCacheTtl = 'Token Metadata API cache TTL in minutes',
TokenMetadataServerUrl = 'Token Metadata API server URL',
UseBlockfrost = 'Enables Blockfrost cached data DB',
UseQueue = 'Enables RabbitMQ',
PaginationPageSizeLimit = 'Pagination page size limit shared across all providers'
}

export type ProviderServerArgs = CommonProgramOptions &
PosgresProgramOptions &
OgmiosProgramOptions &
RabbitMqProgramOptions & {
cardanoNodeConfigPath?: string;
disableDbCache?: boolean;
disableStakePoolMetricApy?: boolean;
tokenMetadataCacheTTL?: number;
tokenMetadataServerUrl?: string;
tokenMetadataRequestTimeout?: number;
epochPollInterval: number;
dbCacheTtl: number;
useBlockfrost?: boolean;
useQueue?: boolean;
paginationPageSizeLimit?: number;
serviceNames: ServiceNames[];
};

export interface LoadProviderServerDependencies {
dnsResolver?: (serviceName: string) => Promise<SrvRecord>;
logger?: Logger;
Expand Down
57 changes: 57 additions & 0 deletions packages/cardano-services/src/Program/programs/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { CommonProgramOptions } from '../options/common';
import { OgmiosProgramOptions } from '../options/ogmios';
import { PosgresProgramOptions } from '../options/postgres';
import { RabbitMqProgramOptions } from '../options/rabbitMq';

/**
* cardano-services programs
*/
export enum Programs {
BlockfrostWorker = 'Blockfrost worker',
ProviderServer = 'Provider server',
RabbitmqWorker = 'RabbitMQ worker'
}

/**
* Used as mount segments, so must be URL-friendly
*/
export enum ServiceNames {
Asset = 'asset',
StakePool = 'stake-pool',
NetworkInfo = 'network-info',
TxSubmit = 'tx-submit',
Utxo = 'utxo',
ChainHistory = 'chain-history',
Rewards = 'rewards'
}

export enum ProviderServerOptionDescriptions {
CardanoNodeConfigPath = 'Cardano node config path',
DbCacheTtl = 'Cache TTL in seconds between 60 and 172800 (two days), an option for database related operations',
DisableDbCache = 'Disable DB cache',
DisableStakePoolMetricApy = 'Omit this metric for improved query performance',
EpochPollInterval = 'Epoch poll interval',
TokenMetadataCacheTtl = 'Token Metadata API cache TTL in minutes',
TokenMetadataServerUrl = 'Token Metadata API server URL',
UseBlockfrost = 'Enables Blockfrost cached data DB',
UseQueue = 'Enables RabbitMQ',
PaginationPageSizeLimit = 'Pagination page size limit shared across all providers'
}

export type ProviderServerArgs = CommonProgramOptions &
PosgresProgramOptions &
OgmiosProgramOptions &
RabbitMqProgramOptions & {
cardanoNodeConfigPath?: string;
disableDbCache?: boolean;
disableStakePoolMetricApy?: boolean;
tokenMetadataCacheTTL?: number;
tokenMetadataServerUrl?: string;
tokenMetadataRequestTimeout?: number;
epochPollInterval: number;
dbCacheTtl: number;
useBlockfrost?: boolean;
useQueue?: boolean;
paginationPageSizeLimit?: number;
serviceNames: ServiceNames[];
};
3 changes: 2 additions & 1 deletion packages/cardano-services/src/Program/services/rabbitmq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { MissingProgramOption } from '../errors';
import { OgmiosTxSubmitProvider } from '@cardano-sdk/ogmios';
import { ProviderError, ProviderFailure, SubmitTxArgs } from '@cardano-sdk/core';
import { RabbitMqOptionDescriptions, RabbitMqProgramOptions } from '../options';
import { ServiceNames, TxWorkerArgs } from '../programs';
import { ServiceNames } from '../programs/types';
import { SrvRecord } from 'dns';
import { TxWorkerArgs } from '../programs/txWorker';
import { isConnectionError } from '@cardano-sdk/util';

export const srvRecordToRabbitmqURL = ({ name, port }: SrvRecord) => new URL(`amqp://${name}:${port}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as OpenApiValidator from 'express-openapi-validator';
import { HttpService } from '../Http';
import { Logger } from 'ts-log';
import { RewardsProvider } from '@cardano-sdk/core';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { providerHandler } from '../util';
import express from 'express';
import path from 'path';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
StakePoolResults
} from './types';
import { DbSyncProvider, DbSyncProviderDependencies, Disposer, EpochMonitor } from '../../util';
import { GenesisData, InMemoryCache, StakePoolMetadataService, UNLIMITED_CACHE_TTL } from '../..';
import { GenesisData } from '../../types';
import {
IDS_NAMESPACE,
REWARDS_HISTORY_LIMIT_DEFAULT,
Expand All @@ -27,8 +27,10 @@ import {
getStakePoolSortType,
queryCacheKey
} from './util';
import { InMemoryCache, UNLIMITED_CACHE_TTL } from '../../InMemoryCache';
import { PromiseOrValue, RunnableModule, isNotNil, resolveObjectValues } from '@cardano-sdk/util';
import { StakePoolBuilder } from './StakePoolBuilder';
import { StakePoolMetadataService } from '../types';
import { toStakePoolResults } from './mappers';
import merge from 'lodash/merge';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { Hash32ByteBase16 } from '@cardano-sdk/crypto';
import { HexBlob } from '@cardano-sdk/util';
import { Logger } from 'ts-log';
import { StakePoolExtMetadataResponse, StakePoolMetadataService } from '../types';
import { StakePoolMetadataResponse, StakePoolMetadataServiceError, StakePoolMetadataServiceFailure } from '../..';
import { StakePoolMetadataResponse } from './types';
import { StakePoolMetadataServiceError, StakePoolMetadataServiceFailure } from './errors';
import { ValidationError, validate } from 'jsonschema';
import { getExtMetadataUrl, getSchemaFormat, loadJsonSchema } from './util';
import { mapToExtendedMetadata } from './mappers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as OpenApiValidator from 'express-openapi-validator';
import { HttpService } from '../Http';
import { Logger } from 'ts-log';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { StakePoolProvider } from '@cardano-sdk/core';
import { providerHandler } from '../util';
import express from 'express';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as OpenApiValidator from 'express-openapi-validator';
import { Cardano, ProviderError, ProviderFailure, TxSubmitProvider } from '@cardano-sdk/core';
import { HttpServer, HttpService } from '../Http';
import { Logger } from 'ts-log';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { providerHandler } from '../util';
import bodyParser from 'body-parser';
import express from 'express';
Expand Down
2 changes: 1 addition & 1 deletion packages/cardano-services/src/Utxo/UtxoHttpService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as OpenApiValidator from 'express-openapi-validator';
import { HttpService } from '../Http';
import { Logger } from 'ts-log';
import { ServiceNames } from '../Program';
import { ServiceNames } from '../Program/programs/types';
import { UtxoProvider } from '@cardano-sdk/core';
import { providerHandler } from '../util';
import express from 'express';
Expand Down
3 changes: 2 additions & 1 deletion packages/cardano-services/src/util/validators.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BuildInfo } from '../Http';
import { CACHE_TTL_LOWER_LIMIT, CACHE_TTL_UPPER_LIMIT } from '../InMemoryCache';
import { MissingProgramOption, ProviderServerOptionDescriptions, ServiceNames } from '../Program';
import { MissingProgramOption } from '../Program/errors/MissingProgramOption';
import { ProviderServerOptionDescriptions, ServiceNames } from '../Program/programs/types';
import { validate } from 'jsonschema';
import fs from 'fs';

Expand Down
1 change: 0 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
"build:cjs": "tsc --build src",
"build": "run-s build:cjs build:esm module-fixup",
"circular-deps:check": "madge --circular dist",
"module-fixup": "shx cp ../../build/cjs-package.json ./dist/cjs/package.json && cp ../../build/esm-package.json ./dist/esm/package.json",
"tscNoEmit": "shx echo typescript --noEmit command not implemented yet",
"cleanup:dist": "shx rm -rf dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
"build:cjs": "tsc --build src",
"build": "run-s build:cjs build:esm module-fixup",
"circular-deps:check": "madge --circular dist",
"circular-deps:check": "madge --circular dist/cjs",
"module-fixup": "shx cp ../../build/cjs-package.json ./dist/cjs/package.json && cp ../../build/esm-package.json ./dist/esm/package.json",
"tscNoEmit": "shx echo typescript --noEmit command not implemented yet",
"cleanup:dist": "shx rm -rf dist",
Expand Down
7 changes: 3 additions & 4 deletions packages/crypto/src/strategies/CmlBip32Ed25519.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { BIP32Path } from '../types';
import { Bip32Ed25519 } from '../Bip32Ed25519';
import {
BIP32Path,
Bip32Ed25519,
Bip32PrivateKeyHex,
Bip32PublicKeyHex,
Ed25519KeyHashHex,
Ed25519PrivateExtendedKeyHex,
Ed25519PrivateNormalKeyHex,
Ed25519PublicKeyHex,
Ed25519SignatureHex
} from '../';
} from '../hexTypes';
import { CardanoMultiplatformLib } from './CML';

import { HexBlob, usingAutoFree } from '@cardano-sdk/util';

const EXTENDED_KEY_HEX_LENGTH = 128;
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
"build:cjs": "tsc --build src",
"build": "run-s build:cjs build:esm module-fixup",
"circular-deps:check": "madge --circular dist",
"circular-deps:check": "madge --circular dist/cjs",
"module-fixup": "shx cp ../../build/cjs-package.json ./dist/cjs/package.json && cp ../../build/esm-package.json ./dist/esm/package.json",
"tscNoEmit": "shx echo typescript --noEmit command not implemented yet",
"cleanup:dist": "shx rm -rf dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"local-network:down": "DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -p local-network-e2e down -v --remove-orphans",
"cardano-services:up": "ts-node --transpile-only ../cardano-services/src/cli.ts start-provider-server",
"cardano-services:up:debug": "npx nodemon --legacy-watch --exec 'node -r ts-node/register --inspect=0.0.0.0:9229 ../cardano-services/src/cli.ts start-provider-server'",
"circular-deps:check": "madge --circular dist",
"circular-deps:check": "madge --circular dist/cjs",
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
"build:cjs": "tsc --build src",
"build": "run-s build:cjs build:esm module-fixup",
Expand Down
Loading

0 comments on commit 070f5e9

Please sign in to comment.