Skip to content

Commit

Permalink
fix: outdated version warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Oct 6, 2023
1 parent 4341cbd commit 238654b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_STAGING }}
TRANSAK_API_KEY: ${{ secrets.TRANSAK_API_KEY }}
PR_NUMBER: ${{ github.event.number }}
WALLET_ENVIRONMENT: feature

jobs:
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export const Header: React.FC<HeaderProps> = memo(props => {

const version = useMemo(() => {
switch (process.env.WALLET_ENVIRONMENT) {
case 'production':
case 'preview':
return `v${VERSION}`;
case 'feature':
return `${BRANCH_NAME}#${COMMIT_SHA?.slice(0, 8)}`;
case 'development':
return 'dev';
case 'production':
case 'preview':
return `v${VERSION}`;
default:
return null;
}
Expand Down
14 changes: 14 additions & 0 deletions src/app/query/common/outdated-pr/outdated-pr.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';

import { GITHUB_ORG, GITHUB_REPO } from '@shared/constants';

export function useOutdatedPrQuery() {
return useQuery({
// enabled: process.env.WALLET_ENVIRONMENT === 'feature',

async queryFn() {
return axios.get(`https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/pulls/${}`);
},
});
}
6 changes: 4 additions & 2 deletions src/shared/environment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export const BRANCH = process.env.GITHUB_REF;
export const BRANCH_NAME = process.env.GITHUB_HEAD_REF;
export const BRANCH_NAME = process.env.GITHUB_HEAD_REF ?? process.env.BRANCH_NAME;
export const PR_NUMBER = process.env.PR_NUMBER;
console.log({ PR_NUMBER });
export const COINBASE_APP_ID = process.env.COINBASE_APP_ID ?? '';
export const COMMIT_SHA = process.env.GITHUB_SHA;
export const COMMIT_SHA = process.env.COMMIT_SHA ?? process.env.GITHUB_SHA;
export const IS_DEV_ENV = process.env.WALLET_ENVIRONMENT === 'development';
export const IS_TEST_ENV = process.env.WALLET_ENVIRONMENT === 'testing';
export const MOONPAY_API_KEY = process.env.MOONPAY_API_KEY ?? '';
Expand Down
26 changes: 17 additions & 9 deletions webpack/webpack.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const SRC_ROOT_PATH = path.join(__dirname, '../', 'src');
const DIST_ROOT_PATH = path.join(__dirname, '../', 'dist');
const { execSync } = require('child_process');

const WALLET_ENVIRONMENT = process.env.WALLET_ENVIRONMENT || 'development';
const WALLET_ENVIRONMENT = process.env.WALLET_ENVIRONMENT ?? 'development';
const ANALYZE_BUNDLE = process.env.ANALYZE === 'true';
const IS_PUBLISHING = !!process.env.IS_PUBLISHING;
const BRANCH = process.env.GITHUB_REF;

const IS_DEV = WALLET_ENVIRONMENT === 'development';
const IS_PROD = !IS_DEV;
const MAIN_BRANCH = 'refs/heads/main';

function executeGitCommand(command) {
return execSync(command)
.toString('utf8')
.replace(/[\n\r\s]+$/, '');
}

const BRANCH_NAME = executeGitCommand('git rev-parse --abbrev-ref HEAD');
const COMMIT_SHA = executeGitCommand('git rev-parse HEAD');

// For non main branch builds, add a random number
const getVersionWithRandomSuffix = ref => {
if (ref === MAIN_BRANCH || !ref || IS_PUBLISHING) return _version;
return `${_version}.${Math.floor(Math.floor(Math.random() * 1000))}`;
};
const VERSION = getVersionWithRandomSuffix(BRANCH);

const smp = new SpeedMeasurePlugin({
disable: !ANALYZE_BUNDLE,
granularLoaderData: true,
});
const VERSION = getVersionWithRandomSuffix(BRANCH_NAME);

const HTML_OPTIONS = {
inject: 'body',
Expand Down Expand Up @@ -247,6 +250,11 @@ const config = {
new webpack.DefinePlugin({
VERSION: JSON.stringify(VERSION),
}),

new webpack.EnvironmentPlugin({
BRANCH_NAME: BRANCH_NAME,
COMMIT_SHA: COMMIT_SHA,
}),
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
Expand Down

0 comments on commit 238654b

Please sign in to comment.