From 5b6b7ae01af067e824fbe224fa75e6311f4df0b2 Mon Sep 17 00:00:00 2001 From: Chris Jacobs Date: Thu, 28 Sep 2023 16:13:14 -0700 Subject: [PATCH] feat: financial statement as a package, but doesn't abide by `@nx/enforce-module-boundaries` --- libs/analytics/src/index.ts | 1 - libs/financial-statement/.babelrc | 12 ++++++ libs/financial-statement/.eslintrc.json | 34 +++++++++++++++ libs/financial-statement/README.md | 7 +++ libs/financial-statement/package.json | 12 ++++++ libs/financial-statement/project.json | 38 ++++++++++++++++ .../src/FinancialStatement.generated.ts | 0 .../src/FinancialStatement.graphql | 0 .../src/FinancialStatement.stories.tsx | 0 .../src/FinancialStatement.tsx | 20 +++++++-- .../src/colors.ts | 0 libs/financial-statement/src/index.ts | 2 + libs/financial-statement/tsconfig.json | 25 +++++++++++ libs/financial-statement/tsconfig.lib.json | 28 ++++++++++++ libs/financial-statement/vite.config.ts | 43 +++++++++++++++++++ libs/shared/utils/src/BigInt.ts | 2 +- tsconfig.base.json | 3 ++ 17 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 libs/financial-statement/.babelrc create mode 100644 libs/financial-statement/.eslintrc.json create mode 100644 libs/financial-statement/README.md create mode 100644 libs/financial-statement/package.json create mode 100644 libs/financial-statement/project.json rename libs/{analytics => financial-statement}/src/FinancialStatement.generated.ts (100%) rename libs/{analytics => financial-statement}/src/FinancialStatement.graphql (100%) rename libs/{analytics => financial-statement}/src/FinancialStatement.stories.tsx (100%) rename libs/{analytics => financial-statement}/src/FinancialStatement.tsx (95%) rename libs/{analytics => financial-statement}/src/colors.ts (100%) create mode 100644 libs/financial-statement/src/index.ts create mode 100644 libs/financial-statement/tsconfig.json create mode 100644 libs/financial-statement/tsconfig.lib.json create mode 100644 libs/financial-statement/vite.config.ts diff --git a/libs/analytics/src/index.ts b/libs/analytics/src/index.ts index af6469dc7..dd238161b 100644 --- a/libs/analytics/src/index.ts +++ b/libs/analytics/src/index.ts @@ -1,2 +1 @@ export * from './TimeLineChart'; -export * from './FinancialStatement'; diff --git a/libs/financial-statement/.babelrc b/libs/financial-statement/.babelrc new file mode 100644 index 000000000..1ea870ead --- /dev/null +++ b/libs/financial-statement/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/financial-statement/.eslintrc.json b/libs/financial-statement/.eslintrc.json new file mode 100644 index 000000000..78d5588fd --- /dev/null +++ b/libs/financial-statement/.eslintrc.json @@ -0,0 +1,34 @@ +{ + "extends": [ + "plugin:@nx/react", + "../../.eslintrc.json" + ], + "ignorePatterns": [ + "!**/*" + ], + "overrides": [ + { + "files": [ + "*.ts", + "*.tsx", + "*.js", + "*.jsx" + ], + "rules": {} + }, + { + "files": [ + "*.ts", + "*.tsx" + ], + "rules": {} + }, + { + "files": [ + "*.js", + "*.jsx" + ], + "rules": {} + } + ] +} diff --git a/libs/financial-statement/README.md b/libs/financial-statement/README.md new file mode 100644 index 000000000..896f5172c --- /dev/null +++ b/libs/financial-statement/README.md @@ -0,0 +1,7 @@ +# financial-statement + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test financial-statement` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/financial-statement/package.json b/libs/financial-statement/package.json new file mode 100644 index 000000000..4ffe0f055 --- /dev/null +++ b/libs/financial-statement/package.json @@ -0,0 +1,12 @@ +{ + "name": "@origin/financial-statement", + "version": "0.0.4", + "main": "./index.js", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js" + } + } +} diff --git a/libs/financial-statement/project.json b/libs/financial-statement/project.json new file mode 100644 index 000000000..9fd87d021 --- /dev/null +++ b/libs/financial-statement/project.json @@ -0,0 +1,38 @@ +{ + "name": "financial-statement", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/financial-statement/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": [ + "{options.outputFile}" + ], + "options": { + "lintFilePatterns": [ + "libs/financial-statement/**/*.{ts,tsx,js,jsx}" + ] + } + }, + "build": { + "executor": "@nx/vite:build", + "outputs": [ + "{options.outputPath}" + ], + "defaultConfiguration": "production", + "options": { + "outputPath": "dist/libs/financial-statement" + }, + "configurations": { + "development": { + "mode": "development" + }, + "production": { + "mode": "production" + } + } + } + } +} diff --git a/libs/analytics/src/FinancialStatement.generated.ts b/libs/financial-statement/src/FinancialStatement.generated.ts similarity index 100% rename from libs/analytics/src/FinancialStatement.generated.ts rename to libs/financial-statement/src/FinancialStatement.generated.ts diff --git a/libs/analytics/src/FinancialStatement.graphql b/libs/financial-statement/src/FinancialStatement.graphql similarity index 100% rename from libs/analytics/src/FinancialStatement.graphql rename to libs/financial-statement/src/FinancialStatement.graphql diff --git a/libs/analytics/src/FinancialStatement.stories.tsx b/libs/financial-statement/src/FinancialStatement.stories.tsx similarity index 100% rename from libs/analytics/src/FinancialStatement.stories.tsx rename to libs/financial-statement/src/FinancialStatement.stories.tsx diff --git a/libs/analytics/src/FinancialStatement.tsx b/libs/financial-statement/src/FinancialStatement.tsx similarity index 95% rename from libs/analytics/src/FinancialStatement.tsx rename to libs/financial-statement/src/FinancialStatement.tsx index afc3bbd8b..48bd51606 100644 --- a/libs/analytics/src/FinancialStatement.tsx +++ b/libs/financial-statement/src/FinancialStatement.tsx @@ -4,17 +4,21 @@ import { alpha, Box, Button, + Experimental_CssVarsProvider, Paper, Stack, Typography, useMediaQuery, useTheme, } from '@mui/material'; +import { queryClient } from '@origin/oeth/shared'; import { useChainlinkEthUsd } from '@origin/shared/providers'; +import { theme } from '@origin/shared/theme'; +import { QueryClientProvider } from '@tanstack/react-query'; import dayjs from 'dayjs'; import LocalizedFormat from 'dayjs/plugin/localizedFormat'; import RelativeTime from 'dayjs/plugin/relativeTime'; -import { useIntl } from 'react-intl'; +import { IntlProvider, useIntl } from 'react-intl'; import { formatEther } from 'viem'; import * as colors from './colors'; @@ -44,6 +48,18 @@ const getTotals = (data: Record>) => { }, [] as number[]); }; +export default function SelfContainedFinancialStatement() { + return ( + + + + + + + + ); +} + export const LiveFinancialStatement = () => { const endOfToday = dayjs().endOf('day').toISOString(); const [sevenDaysAgo] = useState(dayjs().subtract(7, 'days').toISOString()); @@ -121,8 +137,6 @@ export const LiveFinancialStatement = () => { ); }; -export default LiveFinancialStatement; - const FinancialStatementContext = createContext({ ethPrice: undefined as number | undefined, showUsdPrice: false, diff --git a/libs/analytics/src/colors.ts b/libs/financial-statement/src/colors.ts similarity index 100% rename from libs/analytics/src/colors.ts rename to libs/financial-statement/src/colors.ts diff --git a/libs/financial-statement/src/index.ts b/libs/financial-statement/src/index.ts new file mode 100644 index 000000000..06500c227 --- /dev/null +++ b/libs/financial-statement/src/index.ts @@ -0,0 +1,2 @@ +export * from './FinancialStatement'; +export { default } from './FinancialStatement'; diff --git a/libs/financial-statement/tsconfig.json b/libs/financial-statement/tsconfig.json new file mode 100644 index 000000000..465c6c894 --- /dev/null +++ b/libs/financial-statement/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": false, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": false, + "types": [ + "vite/client" + ] + }, + "files": [ + "../../node_modules/@nx/react/typings/cssmodule.d.ts", + "../../node_modules/@nx/react/typings/image.d.ts", + "../../libs/shared/theme/src/theme.d.ts", + "../../apps/oeth/src/env.d.ts" + ], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "extends": "../../tsconfig.base.json" +} diff --git a/libs/financial-statement/tsconfig.lib.json b/libs/financial-statement/tsconfig.lib.json new file mode 100644 index 000000000..0cf346b95 --- /dev/null +++ b/libs/financial-statement/tsconfig.lib.json @@ -0,0 +1,28 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [ + "node", + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts", + "vite/client" + ] + }, + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": [ + "src/**/*.js", + "src/**/*.jsx", + "src/**/*.ts", + "src/**/*.tsx" + ] +} diff --git a/libs/financial-statement/vite.config.ts b/libs/financial-statement/vite.config.ts new file mode 100644 index 000000000..b90ea8e97 --- /dev/null +++ b/libs/financial-statement/vite.config.ts @@ -0,0 +1,43 @@ +/// +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; +import react from '@vitejs/plugin-react'; +import * as path from 'path'; +import { defineConfig } from 'vite'; +import dts from 'vite-plugin-dts'; + +export default defineConfig({ + cacheDir: '../../node_modules/.vite/financial-statement', + + plugins: [ + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + react(), + nxViteTsPaths(), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'financial-statement', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}); diff --git a/libs/shared/utils/src/BigInt.ts b/libs/shared/utils/src/BigInt.ts index d96a687fb..ad952a512 100644 --- a/libs/shared/utils/src/BigInt.ts +++ b/libs/shared/utils/src/BigInt.ts @@ -1,2 +1,2 @@ -export const jsonStringifyReplacer = (key, value) => +export const jsonStringifyReplacer = (key: string, value: unknown) => typeof value === 'bigint' ? value.toString() : value; diff --git a/tsconfig.base.json b/tsconfig.base.json index 8ac9c5a3b..7c07e697e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -23,6 +23,9 @@ "@origin/analytics": [ "libs/analytics/src/index.ts" ], + "@origin/financial-statement": [ + "libs/financial-statement/src/index.ts" + ], "@origin/oeth/history": [ "libs/oeth/history/src/index.ts" ],