diff --git a/package.json b/package.json index 95790c3e5..7c533bb43 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/connect-examples/electron-example/package.json b/packages/connect-examples/electron-example/package.json index b2d7fcc0f..cf87332b6 100644 --- a/packages/connect-examples/electron-example/package.json +++ b/packages/connect-examples/electron-example/package.json @@ -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", diff --git a/packages/connect-examples/expo-example/package.json b/packages/connect-examples/expo-example/package.json index 3de212beb..f2dda7ab2 100644 --- a/packages/connect-examples/expo-example/package.json +++ b/packages/connect-examples/expo-example/package.json @@ -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", @@ -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", diff --git a/packages/core/package.json b/packages/core/package.json index ef0b11a90..99ffd1ec2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -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", @@ -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", diff --git a/packages/core/src/api/CheckBootloaderRelease.ts b/packages/core/src/api/CheckBootloaderRelease.ts index ab98776be..64b7d9850 100644 --- a/packages/core/src/api/CheckBootloaderRelease.ts +++ b/packages/core/src/api/CheckBootloaderRelease.ts @@ -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); diff --git a/packages/hd-ble-sdk/package.json b/packages/hd-ble-sdk/package.json index d9c2e5e2d..6cc6f8e02 100644 --- a/packages/hd-ble-sdk/package.json +++ b/packages/hd-ble-sdk/package.json @@ -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", @@ -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" } } diff --git a/packages/hd-common-connect-sdk/package.json b/packages/hd-common-connect-sdk/package.json index df7d1053b..d5b3e8d20 100644 --- a/packages/hd-common-connect-sdk/package.json +++ b/packages/hd-common-connect-sdk/package.json @@ -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", @@ -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" } } diff --git a/packages/hd-transport-http/package.json b/packages/hd-transport-http/package.json index aeb5f5ed5..a68f5657c 100644 --- a/packages/hd-transport-http/package.json +++ b/packages/hd-transport-http/package.json @@ -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", @@ -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" } } diff --git a/packages/hd-transport-lowlevel/package.json b/packages/hd-transport-lowlevel/package.json index 68ba68fb2..4b3af213d 100644 --- a/packages/hd-transport-lowlevel/package.json +++ b/packages/hd-transport-lowlevel/package.json @@ -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", @@ -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" } } diff --git a/packages/hd-transport-react-native/package.json b/packages/hd-transport-react-native/package.json index bac5d31f8..745b05689 100644 --- a/packages/hd-transport-react-native/package.json +++ b/packages/hd-transport-react-native/package.json @@ -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", @@ -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" } diff --git a/packages/hd-transport-webusb/package.json b/packages/hd-transport-webusb/package.json index 576ea8a45..ba7f1a3c0 100644 --- a/packages/hd-transport-webusb/package.json +++ b/packages/hd-transport-webusb/package.json @@ -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", @@ -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" diff --git a/packages/hd-transport/package.json b/packages/hd-transport/package.json index a2cd006af..7e257762a 100644 --- a/packages/hd-transport/package.json +++ b/packages/hd-transport/package.json @@ -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", diff --git a/packages/hd-web-sdk/package.json b/packages/hd-web-sdk/package.json index 76a9d5d13..c951d5df1 100644 --- a/packages/hd-web-sdk/package.json +++ b/packages/hd-web-sdk/package.json @@ -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", @@ -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", diff --git a/packages/shared/package.json b/packages/shared/package.json index f88ee1aa2..17aba668f 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -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", diff --git a/scripts/moniter-config.json b/scripts/moniter-config.json new file mode 100644 index 000000000..e2aac687b --- /dev/null +++ b/scripts/moniter-config.json @@ -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" + ] + } \ No newline at end of file diff --git a/scripts/monitor.js b/scripts/monitor.js new file mode 100644 index 000000000..1ed3000f3 --- /dev/null +++ b/scripts/monitor.js @@ -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); +}); diff --git a/scripts/publish-yalc.js b/scripts/publish-yalc.js deleted file mode 100644 index 366e028e9..000000000 --- a/scripts/publish-yalc.js +++ /dev/null @@ -1,37 +0,0 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const shell = require('shelljs'); -const chalk = require('chalk'); - -console.log(chalk.green('1. Check system environment...')); - -if (!shell.which('yalc')) { - console.log( - chalk.red('Sorry, this script requires yalc, please install it first. [npm install -g yalc]') - ); - shell.exit(1); -} else { - console.log('Check success.'); -} - -console.log(chalk.green('2. publish library to local registry...')); -shell.cd('./packages/core'); - -const needPublishLibrary = [ - 'core', - 'hd-ble-sdk', - 'hd-common-connect-sdk', - 'hd-transport', - 'hd-transport-http', - 'hd-transport-react-native', - 'hd-transport-webusb', - 'hd-web-sdk', - 'shared', -]; - -needPublishLibrary.forEach((library, index) => { - console.log(chalk.green(`2.${index + 1} publish 「${library}」...`)); - shell.cd(`../${library}`); - shell.exec('yalc publish --replace --changed'); -}); - -console.log(chalk.green('3. Done'));