-
Notifications
You must be signed in to change notification settings - Fork 365
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
usage of javascript/node to allow cross-platform building #5825
Open
Osiris-Team
wants to merge
6
commits into
OneKeyHQ:x
Choose a base branch
from
Osiris-Team:x
base: x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d7e01d5
usage of python to allow cross-platform building
Osiris-Team d145f9d
switch from python to nodejs
Osiris-Team 38ec3d4
Merge branch 'OneKeyHQ:x' into x
Osiris-Team d349e18
switch from python to nodejs
Osiris-Team dc42952
Merge remote-tracking branch 'origin/x' into x
Osiris-Team f30d963
switch from python to nodejs
Osiris-Team File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
function removeDir(dirPath) { | ||
if (fs.existsSync(dirPath)) { | ||
console.log(`Removing directory: ${dirPath}`); | ||
fs.rmSync(dirPath, { recursive: true, force: true }); | ||
} | ||
} | ||
|
||
function removeFile(filePath) { | ||
if (fs.existsSync(filePath)) { | ||
console.log(`Removing file: ${filePath}`); | ||
fs.unlinkSync(filePath); | ||
} | ||
} | ||
|
||
function cleanWorkspace() { | ||
// Clean yarn cache | ||
console.log('Cleaning yarn cache...'); | ||
require('child_process').execSync('yarn cache clean', { stdio: 'inherit' }); | ||
|
||
// Root folder cleanup | ||
removeDir('node_modules'); | ||
removeDir('.expo'); | ||
removeDir('.husky/_'); | ||
removeDir('.app-mono-ts-cache'); | ||
|
||
// Desktop cleanup | ||
removeDir('apps/desktop/node_modules'); | ||
removeDir('apps/desktop/.expo'); | ||
removeDir('apps/desktop/__generated__'); | ||
removeDir('apps/desktop/dist'); | ||
removeDir('apps/desktop/build'); | ||
removeDir('apps/desktop/build-electron'); | ||
removeDir('apps/desktop/public/static/js-sdk'); | ||
removeDir('apps/desktop/public/static/connect'); | ||
removeFile('apps/desktop/public/static/preload.js'); | ||
|
||
// Ext cleanup | ||
removeDir('apps/ext/node_modules'); | ||
removeDir('apps/ext/.expo'); | ||
removeDir('apps/ext/build'); | ||
removeFile('apps/ext/src/entry/injected.js'); | ||
removeFile('apps/ext/src/entry/injected.text-js'); | ||
|
||
// Mobile cleanup | ||
removeDir('apps/mobile/node_modules'); | ||
removeDir('apps/mobile/.expo'); | ||
removeDir('apps/mobile/__generated__'); | ||
removeDir('apps/mobile/ios/Pods'); | ||
removeDir('apps/mobile/ios/build'); | ||
removeDir('apps/mobile/ios/OneKeyWallet/web-embed'); | ||
removeDir('apps/mobile/ios/OneKeyWallet.xcworkspace/xcuserdata'); | ||
removeDir('apps/mobile/src/public/static/connect'); | ||
removeDir('apps/mobile/android/.gradle'); | ||
removeDir('apps/mobile/android/build'); | ||
removeDir('apps/mobile/android/app/build'); | ||
removeDir('apps/mobile/android/lib-keys-secret/build'); | ||
removeDir('apps/mobile/android/lib-keys-secret/.cxx'); | ||
removeDir('apps/mobile/android/app/src/main/assets/web-embed'); | ||
|
||
// Web cleanup | ||
removeDir('apps/web/node_modules'); | ||
removeDir('apps/web/.expo'); | ||
removeDir('apps/web/__generated__'); | ||
removeDir('apps/web/dist'); | ||
removeDir('apps/web/web-build'); | ||
removeDir('apps/web/.expo-shared'); | ||
|
||
// Web-embed cleanup | ||
removeDir('apps/web-embed/node_modules'); | ||
removeDir('apps/web-embed/.expo'); | ||
removeDir('apps/web-embed/__generated__'); | ||
removeDir('apps/web-embed/dist'); | ||
removeDir('apps/web-embed/web-build'); | ||
removeDir('apps/web-embed/.expo-shared'); | ||
|
||
// Package cleanup | ||
removeDir('packages/components/node_modules'); | ||
removeDir('packages/core/node_modules'); | ||
removeDir('packages/kit/node_modules'); | ||
removeFile('packages/kit/src/components/WebView/injectedNative.text-js'); | ||
removeDir('packages/kit-bg/node_modules'); | ||
removeDir('packages/shared/node_modules'); | ||
removeFile('packages/shared/src/web/index.html'); | ||
} | ||
|
||
cleanWorkspace(); | ||
console.log("Workspace cleaned."); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
|
||
function copyFile(src, dest) { | ||
if (fs.existsSync(src)) { | ||
console.log(`Copying ${src} to ${dest}`); | ||
fs.copyFileSync(src, dest); | ||
} else { | ||
console.log(`Source file ${src} does not exist.`); | ||
} | ||
} | ||
|
||
function copyInjected() { | ||
// Copy to Desktop preload.js | ||
copyFile('node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedDesktop.js', | ||
'apps/desktop/public/static/preload.js'); | ||
|
||
// Copy to Extension injected.js | ||
copyFile('node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedExtension.js', | ||
'apps/ext/src/entry/injected.js'); | ||
copyFile('apps/ext/src/entry/injected.js', 'apps/ext/src/entry/injected.text-js'); | ||
|
||
// Copy to Native injectedCode | ||
copyFile('node_modules/@onekeyfe/cross-inpage-provider-injected/dist/injected/injectedNative.js', | ||
'packages/kit/src/components/WebView/injectedNative.text-js'); | ||
|
||
// Copy index html | ||
copyFile('packages/shared/src/web/index.html.ejs', 'packages/shared/src/web/index.html'); | ||
|
||
// Create directory for js-sdk if it doesn't exist | ||
const jsSdkDir = 'apps/desktop/public/static/js-sdk/'; | ||
if (!fs.existsSync(jsSdkDir)) { | ||
console.log(`Creating directory: ${jsSdkDir}`); | ||
fs.mkdirSync(jsSdkDir, { recursive: true }); | ||
} | ||
|
||
// Copy hardware js-sdk iframe files to desktop | ||
const srcJsSdk = 'node_modules/@onekeyfe/hd-web-sdk/build/'; | ||
const destJsSdk = 'apps/desktop/public/static/js-sdk/'; | ||
if (fs.existsSync(srcJsSdk)) { | ||
console.log(`Copying contents of ${srcJsSdk} to ${destJsSdk}`); | ||
execSync(`cp -r ${srcJsSdk}* ${destJsSdk}`, { stdio: 'inherit' }); | ||
} else { | ||
console.log(`Source directory ${srcJsSdk} does not exist.`); | ||
} | ||
|
||
// Build and copy web-embed | ||
const baseDir = path.dirname(__filename); | ||
console.log(`Running web-embed.js in ${baseDir}`); | ||
execSync(`node ${path.join(baseDir, 'web-embed.js')}`, { stdio: 'inherit' }); | ||
} | ||
|
||
copyInjected(); | ||
console.log("Injected files copied."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const fs = require('fs'); | ||
const { execSync } = require('child_process'); | ||
|
||
function postinstall() { | ||
// Run yarn setup:env | ||
console.log('Running yarn setup:env...'); | ||
execSync('yarn setup:env', { stdio: 'inherit' }); | ||
|
||
// Run patch-package | ||
console.log('Running patch-package...'); | ||
execSync('patch-package', { stdio: 'inherit' }); | ||
|
||
// Run yarn copy:inject | ||
console.log('Running yarn copy:inject...'); | ||
execSync('yarn copy:inject', { stdio: 'inherit' }); | ||
|
||
// Remove realm-flipper-plugin-device src directory | ||
const realmDir = 'node_modules/realm-flipper-plugin-device/src'; | ||
if (fs.existsSync(realmDir)) { | ||
console.log(`Removing directory: ${realmDir}`); | ||
fs.rmSync(realmDir, { recursive: true, force: true }); | ||
} | ||
} | ||
|
||
postinstall(); | ||
console.log('Post-installation steps completed.'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to write it like this?