Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use import meta env #187

Merged
merged 5 commits into from
Mar 12, 2025
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
2 changes: 0 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"extends": [
"eslint:recommended",
"plugin:jest-formatting/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
Expand All @@ -30,7 +29,6 @@
//"plugin:prettier/recommended" // Make this the last element so prettier config overrides other formatting rules
],
"plugins": [
"jest-formatting",
"simple-import-sort",
"import",
"react-hooks",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.11.1] - 2025-03-12

### Fixed

- Fixed display of controller for vaults in Balances page

## [1.11.0] - 2025-03-06

### Added
Expand Down
25 changes: 0 additions & 25 deletions jest-setup.ts

This file was deleted.

19 changes: 4 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ar-io/network-portal",
"private": true,
"version": "1.11.0",
"version": "1.11.1",
"type": "module",
"scripts": {
"build": "yarn clean && tsc --build tsconfig.build.json && NODE_OPTIONS=--max-old-space-size=32768 vite build",
Expand All @@ -11,9 +11,7 @@
"lint:fix": "eslint --fix .",
"lint:check": "eslint .",
"preview": "vite preview",
"test": "NODE_ENV=test jest --runInBand",
"test:updateSnapshot": "NODE_ENV=test jest --updateSnapshot",
"test:coverage": "NODE_ENV=test jest --coverage",
"test": "NODE_ENV=test vitest run",
"prepare": "husky || true",
"pre-commit": "lint-staged",
"vis": "yarn vite-bundle-visualizer",
Expand Down Expand Up @@ -61,9 +59,6 @@
"@commitlint/config-conventional": "^17.6.7",
"@sentry/vite-plugin": "^0.7.2",
"@tailwindcss/typography": "^0.5.15",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.1",
"@types/eslint": "^8.4.10",
"@types/file-saver": "^2.0.7",
"@types/jest": "^29.5.10",
Expand All @@ -77,12 +72,10 @@
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.17",
"babel-jest": "^29.7.0",
"core-js": "^3.36.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-jsx-no-inline-style": "^0.0.5",
"eslint-plugin-prettier": "^4.2.1",
Expand All @@ -92,10 +85,6 @@
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-tailwindcss": "^3.14.2",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-location-mock": "^2.0.0",
"jest-transform-stub": "^2.0.0",
"lint-staged": "^15.2.2",
"lodash": "^4.17.21",
"nyc": "^15.1.0",
Expand All @@ -108,13 +97,13 @@
"tailwind-scrollbar": "^3.1.0",
"tailwindcss": "^3.4.1",
"tailwindcss-animate": "^1.0.7",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.3",
"vite": "^5.1.0",
"vite-bundle-visualizer": "^1.0.1",
"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-svgr": "^4.2.0"
"vite-plugin-svgr": "^4.2.0",
"vitest": "^3.0.8"
},
"lint-staged": {
"{lib,packages}/**/src/**/*.{ts,tsx}": [
Expand Down
3 changes: 2 additions & 1 deletion src/components/GlobalDataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const GlobalDataProvider = ({ children }: { children: ReactElement }) => {

useEffect(() => {
const update = async () => {
queryClient.resetQueries();
await queryClient.cancelQueries();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the cancel to cancel any existing queries prior to call to resetQueries. Saw some oddities when switching process IDs (e.g., mainnet to testnet) and this seems to have helped.

await queryClient.resetQueries();

// perform this first as retrieving the current epic takes some time
const { Ticker } = await arioReadSDK.getInfo();
Expand Down
17 changes: 9 additions & 8 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import Ar from 'arweave/web/ar';
import { ArweaveTransactionID } from './utils/ArweaveTransactionId';

export const APP_NAME = 'AR-IO-Network-Portal-App';
export const APP_VERSION = process.env.npm_package_version || '1.0.0';

export const APP_VERSION = __NPM_PACKAGE_VERSION__ || '1.0.0';
export const WRITE_OPTIONS = {
tags: [
{
Expand All @@ -17,19 +18,19 @@ export const WRITE_OPTIONS = {
};
export const ARIO_DOCS_URL = 'https://docs.ar.io';
export const ARIO_PROCESS_ID = new ArweaveTransactionID(
process.env.VITE_ARIO_PROCESS_ID ?? ARIO_DEVNET_PROCESS_ID,
import.meta.env.VITE_ARIO_PROCESS_ID ?? ARIO_DEVNET_PROCESS_ID,
);
export const AO_CU_URL = process.env.VITE_AO_CU_URL || 'https://cu.ardrive.io';
export const AO_CU_URL = import.meta.env.VITE_AO_CU_URL || 'https://cu.ardrive.io';
export const DEFAULT_ARWEAVE_PROTOCOL =
process.env.VITE_GATEWAY_PROTOCOL ?? 'https';
import.meta.env.VITE_GATEWAY_PROTOCOL ?? 'https';
export const DEFAULT_ARWEAVE_HOST =
process.env.VITE_GATEWAY_HOST ?? 'arweave.net';
import.meta.env.VITE_GATEWAY_HOST ?? 'arweave.net';

export const DEFAULT_ARWEAVE_GQL_ENDPOINT =
process.env.VITE_ARWEAVE_GQL_ENDPOINT ??
import.meta.env.VITE_ARWEAVE_GQL_ENDPOINT ??
'https://arweave-search.goldsky.com/graphql';
export const DEFAULT_ARWEAVE_PORT =
Number(process.env.VITE_GATEWAY_PORT) ?? 443;
Number(import.meta.env.VITE_GATEWAY_PORT) ?? 443;

export const THEME_TYPES = {
LIGHT: 'light',
Expand Down Expand Up @@ -61,7 +62,7 @@ export const OPERATOR_EAY_TOOLTIP_FORMULA =
// OBSERVATION ASSESSMENT CONSTANTS
export const NAME_PASS_THRESHOLD = 0.8;
export const REFERENCE_GATEWAY_FQDN =
process.env.VITE_REFERENCE_GATEWAY_FQDN ?? 'arweave.net';
import.meta.env.VITE_REFERENCE_GATEWAY_FQDN ?? 'arweave.net';

export const REDELEGATION_FEE_TOOLTIP_TEXT =
'Redelegation fees are assessed at 10% per redelegation performed since the last fee reset, up to 60%. Fees are reset when no redelegations are performed in the last 7 days.';
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const __NPM_PACKAGE_VERSION__: string;
6 changes: 3 additions & 3 deletions src/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ARIO_DOCS_URL } from '@src/constants';
import { APP_VERSION, ARIO_DOCS_URL } from '@src/constants';
import { useEffect, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';

Expand Down Expand Up @@ -156,8 +156,8 @@ const Sidebar = () => {
className="grow pl-3 text-left text-xs text-low/50"
onClick={() => setShowChangeLogModal(true)}
>
v{process.env.npm_package_version}-
{process.env.VITE_GITHUB_HASH?.slice(0, 6)}
v{APP_VERSION}-
{import.meta.env.VITE_GITHUB_HASH?.slice(0, 6)}
</button>
)}
<button onClick={() => setSidebarOpen(!sidebarOpen)}>
Expand Down
10 changes: 0 additions & 10 deletions tests/App.test.tsx

This file was deleted.

74 changes: 0 additions & 74 deletions tests/__snapshots__/App.test.tsx.snap

This file was deleted.

15 changes: 3 additions & 12 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="vitest/config" />
import { sentryVitePlugin } from '@sentry/vite-plugin';
import react from '@vitejs/plugin-react';
import path from 'path';
Expand Down Expand Up @@ -37,22 +38,12 @@ export default defineConfig({
],
base: '',
define: {
"__NPM_PACKAGE_VERSION__": JSON.stringify(process.env.npm_package_version),
'process.env': {
// DO NOT EXPOSE THE ENTIRE process.env HERE - sensitive information on CI/CD could be exposed.
VITE_ARIO_PROCESS_ID: process.env.VITE_ARIO_PROCESS_ID,
VITE_AO_CU_URL: process.env.VITE_AO_CU_URL,
VITE_GATEWAY_PROTOCOL: process.env.VITE_GATEWAY_PROTOCOL,
VITE_GATEWAY_HOST: process.env.VITE_GATEWAY_HOST,
VITE_ARWEAVE_GQL_ENDPOINT: process.env.VITE_ARWEAVE_GQL_ENDPOINT,
VITE_GATEWAY_PORT: process.env.VITE_GATEWAY_PORT,
VITE_REFERENCE_GATEWAY_FQDN: process.env.VITE_REFERENCE_GATEWAY_FQDN,
VITE_GITHUB_HASH: process.env.VITE_GITHUB_HASH,
npm_package_version: process.env.npm_package_version
// defining here as an empty object as there are errors otherwise
},
'process.version': `"${process.version}"`,
VITE_CONFIG: {
version: JSON.stringify(process.env.npm_package_version),
},
},
resolve: {
alias: {
Expand Down
56 changes: 56 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// <reference types="vitest/config" />
import { sentryVitePlugin } from '@sentry/vite-plugin';
import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import svgr from 'vite-plugin-svgr';

// https://vitejs.dev/config/
export default defineConfig({
esbuild: false,
build: {
sourcemap: true,
minify: true,
cssMinify: true,
},
plugins: [
svgr(),
react(),
nodePolyfills(),
...(process.env.VITE_NODE_ENV
? [
sentryVitePlugin({
org: process.env.VITE_SENTRY_ORG,
project: process.env.VITE_SENTRY_PROJECT,
ignore: ['node_modules', 'vite.config.ts'],
authToken: process.env.VITE_SENTRY_AUTH_TOKEN,
sourcemaps: {
assets: './dist/**',
},
release: process.env.VITE_SENTRY_RELEASE,
deploy: {
env: process.env.VITE_NODE_ENV,
},
}),
]
: []),
],
base: '',
test: {
globals: true,
},
define: {
"__NPM_PACKAGE_VERSION__": JSON.stringify(process.env.npm_package_version),
'process.env': {
// DO NOT EXPOSE THE ENTIRE process.env HERE - sensitive information on CI/CD could be exposed.
// defining here as an empty object as there are errors otherwise
},
},
resolve: {
alias: {
'@tests': path.resolve(__dirname) + '/tests',
'@src': path.resolve(__dirname) + '/src',
},
},
});
Loading