Skip to content

Commit

Permalink
fix: check pro boot update (#335)
Browse files Browse the repository at this point in the history
* fix: check pro boot update

* chore: release version 1.0.1
  • Loading branch information
ByteZhang1024 authored Jun 27, 2024
1 parent 95900f4 commit a31e8ca
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 77 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dev:transport-rn": "cd ./packages/hd-transport-react-native && yarn dev",
"dev:transport-lowlevel": "cd ./packages/hd-transport-lowlevel && yarn dev",
"dev:shared": "cd ./packages/shared && yarn dev",
"publish:yalc": "yarn setup && node ./scripts/publish-yalc.js"
"debug:watcher": "node ./scripts/monitor.js"
},
"devDependencies": {
"@babel/core": "^7.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-examples/electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hardware-example",
"productName": "HardwareExample",
"executableName": "onekey-hardware-example",
"version": "1.0.0",
"version": "1.0.1",
"author": "OneKey",
"description": "End-to-end encrypted workspaces for teams",
"main": "dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expo-example",
"version": "1.0.0",
"version": "1.0.1",
"scripts": {
"start": "yarn expo start --dev-client",
"android": "yarn expo run:android",
Expand All @@ -15,10 +15,10 @@
"@noble/ed25519": "^2.1.0",
"@noble/hashes": "^1.3.3",
"@noble/secp256k1": "^1.7.1",
"@onekeyfe/hd-ble-sdk": "^1.0.0",
"@onekeyfe/hd-common-connect-sdk": "^1.0.0",
"@onekeyfe/hd-core": "^1.0.0",
"@onekeyfe/hd-web-sdk": "^1.0.0",
"@onekeyfe/hd-ble-sdk": "^1.0.1",
"@onekeyfe/hd-common-connect-sdk": "^1.0.1",
"@onekeyfe/hd-core": "^1.0.1",
"@onekeyfe/hd-web-sdk": "^1.0.1",
"@onekeyfe/react-native-ble-plx": "3.0.0",
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-picker/picker": "2.6.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-core",
"version": "1.0.0",
"version": "1.0.1",
"description": "> TODO: description",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -25,8 +25,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport": "^1.0.0",
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport": "^1.0.1",
"axios": "^0.27.2",
"bignumber.js": "^9.0.2",
"bytebuffer": "^5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api/CheckBootloaderRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class CheckBootloaderRelease extends BaseMethod {
features,
this.payload.willUpdateFirmwareVersion
);
} else if (deviceType === 'touch') {
} else if (DeviceModelToTypes.model_touch.includes(deviceType)) {
shouldUpdate = checkNeedUpdateBootForTouch(features);
}
const releaseInfo = getBootloaderReleaseInfo(features);
Expand Down
8 changes: 4 additions & 4 deletions packages/hd-ble-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-ble-sdk",
"version": "1.0.0",
"version": "1.0.1",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -20,8 +20,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "^1.0.0",
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport-react-native": "^1.0.0"
"@onekeyfe/hd-core": "^1.0.1",
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport-react-native": "^1.0.1"
}
}
12 changes: 6 additions & 6 deletions packages/hd-common-connect-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-common-connect-sdk",
"version": "1.0.0",
"version": "1.0.1",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -20,10 +20,10 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-core": "^1.0.0",
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport-http": "^1.0.0",
"@onekeyfe/hd-transport-lowlevel": "^1.0.0",
"@onekeyfe/hd-transport-webusb": "^1.0.0"
"@onekeyfe/hd-core": "^1.0.1",
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport-http": "^1.0.1",
"@onekeyfe/hd-transport-lowlevel": "^1.0.1",
"@onekeyfe/hd-transport-webusb": "^1.0.1"
}
}
6 changes: 3 additions & 3 deletions packages/hd-transport-http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-http",
"version": "1.0.0",
"version": "1.0.1",
"description": "hardware http transport",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand All @@ -24,8 +24,8 @@
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport": "^1.0.0",
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport": "^1.0.1",
"axios": "^0.27.2"
}
}
6 changes: 3 additions & 3 deletions packages/hd-transport-lowlevel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-lowlevel",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,7 +19,7 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport": "^1.0.0"
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport": "^1.0.1"
}
}
6 changes: 3 additions & 3 deletions packages/hd-transport-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-react-native",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
"main": "dist/index.js",
Expand All @@ -19,8 +19,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport": "^1.0.0",
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport": "^1.0.1",
"@onekeyfe/react-native-ble-plx": "3.0.0",
"react-native-ble-manager": "^8.1.0"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/hd-transport-webusb/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport-webusb",
"version": "1.0.0",
"version": "1.0.1",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "MIT",
Expand All @@ -20,8 +20,8 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport": "^1.0.0"
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport": "^1.0.1"
},
"devDependencies": {
"@types/w3c-web-usb": "^1.0.6"
Expand Down
2 changes: 1 addition & 1 deletion packages/hd-transport/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-transport",
"version": "1.0.0",
"version": "1.0.1",
"description": "> TODO: description",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
Expand Down
10 changes: 5 additions & 5 deletions packages/hd-web-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-web-sdk",
"version": "1.0.0",
"version": "1.0.1",
"author": "OneKey",
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
"license": "ISC",
Expand All @@ -21,10 +21,10 @@
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "^0.0.17",
"@onekeyfe/hd-core": "^1.0.0",
"@onekeyfe/hd-shared": "^1.0.0",
"@onekeyfe/hd-transport-http": "^1.0.0",
"@onekeyfe/hd-transport-webusb": "^1.0.0"
"@onekeyfe/hd-core": "^1.0.1",
"@onekeyfe/hd-shared": "^1.0.1",
"@onekeyfe/hd-transport-http": "^1.0.1",
"@onekeyfe/hd-transport-webusb": "^1.0.1"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/hd-shared",
"version": "1.0.0",
"version": "1.0.1",
"description": "Hardware SDK's shared tool library",
"keywords": [
"Hardware-SDK",
Expand Down
25 changes: 25 additions & 0 deletions scripts/moniter-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"basePath": "./packages",
"targetEnvVar": "APP_MONOREPO_LOCAL_PATH",
"defaultWatchDir": "dist",
"projects": [
"hd-ble-sdk",
"hd-transport",
"hd-transport-lowlevel",
"hd-transport-webusb",
"shared",
"core",
"hd-common-connect-sdk",
"hd-transport-http",
"hd-transport-react-native",
"hd-web-sdk"
],
"specialProjects": {
"hd-web-sdk": ["dist", "build"]
},
"ignoredPaths": [
"node_modules",
".git",
"*.log"
]
}
91 changes: 91 additions & 0 deletions scripts/monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-disable @typescript-eslint/no-var-requires */
require('dotenv').config();
const chokidar = require('chokidar');
const fs = require('fs-extra');
const path = require('path');

const config = require('./moniter-config.json');

const targetDir = process.env[config.targetEnvVar];

if (!targetDir) {
console.error(
'Target directory APP_MONOREPO_LOCAL_PATH is not set. Please specify it in the .env file.'
);
process.exit(1);
}

const { basePath, projects, specialProjects } = config;

const watchPaths = projects.flatMap(project => {
const watchDirs = specialProjects[project] || [config.defaultWatchDir];
return watchDirs.map(dir => {
const dirPath = path.join(basePath, project, dir);
console.log('Observe directory file changes:', dirPath);
return dirPath;
});
});

function copyFile(src, dest, ignoreLog) {
fs.copy(src, dest, { overwrite: true })
.then(() => {
if (!ignoreLog) {
console.log(`Copied ${src} to ${dest}`);
}
})
.catch(err => console.error(`Error copying ${src} to ${dest}:`, err));
}

const watcher = chokidar.watch(watchPaths, {
ignored: [
// eslint-disable-next-line no-useless-escape
/(^|[\/\\])\./, // 忽略点文件
...config.ignoredPaths.map(p => `**/${p}/**`),
],
persistent: true,
});

async function handleFileEvent(filePath, eventType) {
const relativePath = path.relative(basePath, filePath);
const [projectName, watchDir, ...restPath] = relativePath.split(path.sep);

if (!projects.includes(projectName)) {
console.warn(`Project ${projectName} not found in config. Skipping file: ${filePath}`);
return;
}

const packageJsonPath = path.join(basePath, projectName, 'package.json');
if (await fs.pathExists(packageJsonPath)) {
const packageJson = await fs.readJson(packageJsonPath);
const packageName = packageJson.name;

const destPath = path.join(targetDir, 'node_modules', packageName, watchDir, ...restPath);

try {
if (eventType === 'delete') {
await fs.remove(destPath);
console.log(`Removed ${destPath}`);
} else {
copyFile(filePath, destPath, eventType === 'add');
}
} catch (err) {
console.error(`Error ${eventType === 'delete' ? 'removing' : 'copying'} ${filePath}:`, err);
}
} else {
console.warn(`package.json not found for project ${projectName}. Skipping file: ${filePath}`);
}
}

watcher
.on('add', filePath => handleFileEvent(filePath, 'add'))
.on('change', filePath => handleFileEvent(filePath, 'change'))
.on('unlink', filePath => handleFileEvent(filePath, 'delete'))
.on('error', error => console.error(`Watcher error: ${error}`))
.on('ready', () => console.log('Initial scan complete. Ready for changes.'));

process.on('SIGINT', () => {
console.log('Closing watcher...');
watcher.close();
console.log('Watcher closed. Exiting.');
process.exit(0);
});
37 changes: 0 additions & 37 deletions scripts/publish-yalc.js

This file was deleted.

0 comments on commit a31e8ca

Please sign in to comment.