Skip to content

Commit

Permalink
Merge pull request #249 from Outblock/dev
Browse files Browse the repository at this point in the history
[Release] 2.6.0
  • Loading branch information
lmcmz authored Dec 6, 2024
2 parents 0068a7c + a8f773d commit b3fff40
Show file tree
Hide file tree
Showing 386 changed files with 11,500 additions and 12,394 deletions.
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Related Issue
<!-- If this PR addresses an issue, link it here (e.g., "Closes #123") -->

## Summary of Changes
<!-- Provide a concise description of the changes made in this PR.
What functionality was added, updated, or fixed? -->

## Need Regression Testing
<!-- Indicate whether this PR requires regression testing and why. -->
- [ ] Yes
- [ ] No

## Risk Assessment
<!-- Assess the risk level of this PR:
- Low: Minimal impact, straightforward changes.
- Medium: Potential for some edge cases or indirect effects.
- High: Could affect critical functionality or many users.
-->
- [ ] Low
- [ ] Medium
- [ ] High

## Additional Notes
<!-- Add any other context or comments about the PR here -->

## Screenshots (if applicable)
<!-- Attach any screenshots that help explain your changes -->
99 changes: 99 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Production Build

on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
push:
branches: [dev, master]

jobs:
build:
runs-on: ubuntu-latest
environment: production

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Create .env.pro file
run: |
cat << EOF > .env.pro
# Git info
COMMIT_SHA="${{ github.sha }}"
BRANCH_NAME="${{ github.ref_name }}"
PR_TITLE="${{ github.event.pull_request.title || '' }}"
PR_NUMBER="${{ github.event.pull_request.number || '' }}"
# Google drive
GD_BACKUP_NAME="${{ vars.GD_BACKUP_NAME }}"
GD_FOLDER="${{ vars.GD_FOLDER }}"
GD_AES_KEY="${{ secrets.GD_AES_KEY }}"
GD_IV="${{ secrets.GD_IV }}"
GOOGLE_API="${{ secrets.GOOGLE_API }}"
FB_TOKEN="${{ secrets.FB_TOKEN }}"
# firebase
FB_API_KEY="${{ secrets.FB_API_KEY }}"
FB_AUTH_DOMAIN="${{ secrets.FB_AUTH_DOMAIN }}"
FB_DATABASE_URL="${{ secrets.FB_DATABASE_URL }}"
FB_PROJECTID="${{ secrets.FB_PROJECTID }}"
FB_STORAGE_BUCKET="${{ secrets.FB_STORAGE_BUCKET }}"
FB_MESSAGING_SENDER_ID="${{ secrets.FB_MESSAGING_SENDER_ID }}"
FB_APP_ID="${{ secrets.FB_APP_ID }}"
FB_MEASUREMENT_ID="${{ secrets.FB_MEASUREMENT_ID }}"
FB_FUNCTIONS="${{ secrets.FB_FUNCTIONS }}"
# manifest
OAUTH2_CLIENT_ID="${{ secrets.OAUTH2_CLIENT_ID }}"
OAUTH2_SCOPES="${{ vars.OAUTH2_SCOPES }}"
WC_PROJECTID="${{ secrets.WC_PROJECTID }}"
MIXPANEL_TOKEN="${{ secrets.MIXPANEL_TOKEN }}"
EOF
- name: Build production
run: pnpm run build:ci
env:
CI: true
COMMIT_SHA: ${{ github.sha }}
BRANCH_NAME: ${{ github.ref_name }}
PR_TITLE: ${{ github.event.pull_request.title || '' }}
PR_NUMBER: ${{ github.event.pull_request.number || '' }}

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: extension-build
path: dist/

- name: Check build size
run: |
echo "Build size:"
du -sh dist/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ yarn.lock
.env.pro
dist.zip
_raw/manifest.json
_raw/react-devtools.js
yarn-error.log
dist2
src/background/utils/firebase.config.json
Expand Down
2 changes: 1 addition & 1 deletion _raw/manifest/manifest.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "FlowWallet-dev",
"short_name": "__MSG_appName__",
"version": "2.5.21",
"version": "2.6.0",
"default_locale": "en",
"description": "__MSG_appDescription__",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion _raw/manifest/manifest.pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
"version": "2.5.21",
"version": "2.6.0",
"default_locale": "en",
"description": "__MSG_appDescription__",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion build/plugins/AssetReplacePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AssetReplacePlugin {

for (const chunk of compilation.chunks.values()) {
const fileName = chunk.files.values().next().value;
if (!replaceArr.includes(([, assetName]) => assetName === fileName)) {
if (!replaceArr.some(([, assetName]) => assetName === fileName)) {
compilation.updateAsset(fileName, (content) => {
const result = replaceFn(content.source());

Expand Down
13 changes: 11 additions & 2 deletions build/plugins/FirebaseFixPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ class FirebaseFixPlugin {
if (/\.(js|jsx)$/.test(name)) {
let content = asset.source();

console.log('About to fix firebase stuff', name);
console.log('typeof content', typeof content);
// Convert Buffer to string if needed
if (Buffer.isBuffer(content)) {
content = content.toString('utf-8');
}

// Convert other types to string if needed
if (typeof content !== 'string') {
content = content.toString();
}
// Replace the _loadJS function
content = content.replace(
/function\s*\w*\s*_loadJS\([\w\s,]*\)\s*\{([\w\W]*?)\}$/gim,
Expand All @@ -27,6 +33,9 @@ class FirebaseFixPlugin {
''
);

// https://apis.google.com/js/api.js
content = content.replace(/https:\/\/apis\.google\.com\/js\/api\.js/g, '');

content = content.replace(
/_loadJS\(`https:\/\/apis\.google\.com\/js\/api\.js(\?onload=\$\{([^}]+)\})?`\)/g,
'_loadJS(`${$1}`)'
Expand Down
45 changes: 44 additions & 1 deletion build/prepareManifest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const fs = require('fs-extra');
const http = require('http');
// require('dotenv').config();

const PROJECT_ROOT = path.resolve(__dirname, '..');
Expand All @@ -8,6 +9,35 @@ const mode = args[0];

require('dotenv').config({ path: `.env.${mode}` });

const OAUTH2_SCOPES = process.env.OAUTH2_SCOPES || '';

const DEVTOOLS_URL = 'http://localhost:8097';

async function fetchDevTools() {
return new Promise((resolve, reject) => {
const request = http.get(DEVTOOLS_URL, (response) => {
if (response.statusCode !== 200) {
reject(new Error(`Failed to fetch: ${response.statusCode}`));
return;
}

let data = '';
response.on('data', (chunk) => (data += chunk));
response.on('end', () => {
const modifiedScript = `
// React DevTools for Chrome Extension
(function() {
${data}
})();
`;
resolve(modifiedScript);
});
});

request.on('error', reject);
});
}

async function prepare() {
console.log(process.env.NODE_ENV);
console.log(process.env.OAUTH2_CLIENT_ID);
Expand All @@ -17,12 +47,25 @@ async function prepare() {

manifest.oauth2 = {
client_id: process.env.OAUTH2_CLIENT_ID,
scopes: process.env.OAUTH2_SCOPES.split(','),
scopes: OAUTH2_SCOPES.split(','),
};

if (mode == 'dev') {
manifest.key = process.env.MANIFEST_KEY;
try {
const devToolsScript = await fetchDevTools();
fs.writeFileSync(path.resolve(__dirname, '../_raw/react-devtools.js'), devToolsScript);
console.log('✅ React DevTools source fetched successfully');
} catch (error) {
console.warn('⚠️ Failed to fetch React DevTools. Run the devtools server first');
// Write empty file if fetch fails
fs.writeFileSync(
path.resolve(__dirname, '../_raw/react-devtools.js'),
'// React DevTools not available'
);
}
}

fs.writeJSONSync(manifestPath, manifest, { spaces: 2 });

return '';
Expand Down
4 changes: 2 additions & 2 deletions build/release.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const path = require('path');
const { prompt } = require('enquirer');
const { prompt: enquirerPrompt } = require('enquirer');
const fs = require('fs-extra');
const shell = require('shelljs');
const zipdir = require('zip-dir');

const PROJECT_ROOT = path.resolve(__dirname, '..');

async function release() {
const input = await prompt({
const input = await enquirerPrompt({
type: 'input',
name: 'version',
message: '[Flow Wallet] Please input the release version:',
Expand Down
Loading

0 comments on commit b3fff40

Please sign in to comment.