Skip to content
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
wants to merge 10 commits into
base: x
Choose a base branch
from

Conversation

Osiris-Team
Copy link

@Osiris-Team Osiris-Team commented Sep 13, 2024

At the current state the build fails when following the simple instructions in the README on Windows.
This fixes it.

Summary by CodeRabbit

  • 新功能
    • 添加了用于清理开发工作区的脚本。
    • 添加了用于复制注入文件的脚本。
    • 添加了用于执行后安装步骤的脚本。
  • 依赖更新
    • 新增依赖:"cross-env-shell": "^7.0.3"
  • 脚本更新
    • 更新了postinstallcopy:inject脚本为Node.js脚本。
    • 新增clean脚本用于清理工作区。

Copy link

codesandbox bot commented Sep 13, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

what-the-diff bot commented Sep 13, 2024

PR总结

  • 更新了README.md
    • 添加了Python安装的要求
  • 引入了clean_workspace.py脚本
    • 用于清理工作区, 替换先前使用的Shell脚本
  • 删除了旧的Shell脚本 clean_workspace.sh
  • 删除了旧的Shell脚本copy-injected.sh并引入copy_injected.py
    • 用来复制注入的文件
  • 添加了postinstall.py脚本
    • 用于处理安装后步骤, 替换先前的postinstall.sh
  • 更新了package.json
    • 使用Python脚本替代Shell脚本进行清理和复制任务, 确保跨平台兼容性
  • 添加了cross-env-shell依赖
    • 以跨平台方式管理环境变量

@sidmorizon
Copy link
Contributor

Thanks for your contribution @Osiris-Team

But we're not planning to introduce Python scripts into the project, you can consider converting the Python scripts to Node scripts.

@Osiris-Team
Copy link
Author

Osiris-Team commented Sep 14, 2024

Oh yeah that makes sense, didn't think about that!
-> Fixed

@huhuanming
Copy link
Contributor

huhuanming commented Sep 14, 2024

Thanks for your contribution @Osiris-Team.

but development/scripts/copy_injected.js is still a python file.

Maybe you can make modifications based on this draft PR #5830

@Osiris-Team
Copy link
Author

my bad forgot to copy over, fixed

@Osiris-Team Osiris-Team changed the title usage of python to allow cross-platform building usage of javascript/node to allow cross-platform building Sep 14, 2024
@huhuanming
Copy link
Contributor

and apps/desktop/dist/build_keytar.sh need to be fixed.

After all the files have been modified, I will help you package and test it.

Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

此次更改引入了多个新的脚本文件,分别用于清理开发工作区、复制注入文件和执行安装后步骤。package.json文件也进行了更新,主要涉及脚本的转换和新依赖的添加。所有新脚本均采用Node.js实现,替代了之前的bash脚本,提升了跨平台兼容性。

Changes

文件 更改摘要
development/scripts/*.js 新增了 clean_workspace.jscopy_injected.jspostinstall.js,分别用于清理工作区、复制文件和执行安装后步骤。每个脚本都定义了相应的主要功能和操作。
package.json 更新了 setup:envpostinstallcopy:inject 脚本,均转为Node.js实现。新增了 clean 脚本,并添加了 cross-env-shell 作为依赖,版本为 ^7.0.3。旧的bash脚本被移除。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NodeJS
    participant FileSystem

    User->>NodeJS: 执行 postinstall()
    NodeJS->>FileSystem: 执行 yarn setup:env
    NodeJS->>FileSystem: 执行 patch-package
    NodeJS->>FileSystem: 执行 yarn copy:inject
    NodeJS->>FileSystem: 检查并删除 node_modules/realm-flipper-plugin-device/src
    Note over NodeJS: 所有步骤完成
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between b67d027 and 5c14cdd.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (7)
  • development/scripts/clean_workspace.js (1 hunks)
  • development/scripts/clean_workspace.sh (0 hunks)
  • development/scripts/copy-injected.sh (0 hunks)
  • development/scripts/copy_injected.js (1 hunks)
  • development/scripts/postinstall.js (1 hunks)
  • development/scripts/postinstall.sh (0 hunks)
  • package.json (2 hunks)
Files not reviewed due to no reviewable changes (3)
  • development/scripts/clean_workspace.sh
  • development/scripts/copy-injected.sh
  • development/scripts/postinstall.sh
Additional context used
Biome
development/scripts/clean_workspace.js

[error] 1-1: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 2-2: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 21-21: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

development/scripts/copy_injected.js

[error] 1-1: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 2-2: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 3-3: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

development/scripts/postinstall.js

[error] 1-1: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 2-2: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

Additional comments not posted (8)
development/scripts/postinstall.js (1)

1-26: 总体评价

脚本功能正确,但有改进空间:

  1. 用 node: 协议导入
  2. 加强错误处理
  3. 考虑用异步方法提高性能

整体来说,代码简洁明了,易于理解。修复这些小问题后会更稳健。

Tools
Biome

[error] 1-1: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)


[error] 2-2: A Node.js builtin module should be imported with the node: protocol.

Using the node: protocol is more explicit and signals that the imported module belongs to Node.js.
Unsafe fix: Add the node: protocol.

(lint/style/useNodejsImportProtocol)

development/scripts/copy_injected.js (2)

5-12: copyFile 函数写得不错

函数简单明了,还处理了源文件不存在的情况。日志输出也很清晰。干得好!


54-55: 函数调用没问题

简单明了,很好。日志消息清晰地表明了操作完成。

development/scripts/clean_workspace.js (1)

4-16: 实用函数设计合理

removeDirremoveFile 函数设计得很好。它们检查目标是否存在,执行删除操作,并记录行为。这种方法安全可靠。

package.json (4)

15-15: 清理脚本更通用了

新的clean脚本用Node.js替代了bash命令。这样做:

  1. 提高了跨平台兼容性
  2. 与项目向JavaScript迁移的方向一致

好改动!


16-16: 安装后脚本更好了

postinstall脚本现在用Node.js代替了bash。这个改动:

  1. 保持了项目风格一致性
  2. 提高了跨平台兼容性

干得好!


17-17: 注入脚本更通用了

copy:inject脚本改用Node.js了。这样做:

  1. 与项目整体风格一致
  2. 提高了跨平台兼容性

很棒的改进!


91-91: 新依赖提升了兼容性

添加cross-env-shell依赖:

  1. 支持了setup:env脚本的跨平台运行
  2. 与项目提高兼容性的目标一致

好主意!

development/scripts/postinstall.js Show resolved Hide resolved
development/scripts/postinstall.js Show resolved Hide resolved
development/scripts/postinstall.js Show resolved Hide resolved
development/scripts/copy_injected.js Show resolved Hide resolved
development/scripts/copy_injected.js Show resolved Hide resolved
development/scripts/copy_injected.js Show resolved Hide resolved
development/scripts/copy_injected.js Show resolved Hide resolved
development/scripts/clean_workspace.js Show resolved Hide resolved
development/scripts/clean_workspace.js Show resolved Hide resolved
development/scripts/clean_workspace.js Show resolved Hide resolved
@originalix originalix marked this pull request as draft September 23, 2024 02:52
@originalix originalix marked this pull request as ready for review September 23, 2024 07:12
@originalix originalix enabled auto-merge (squash) September 23, 2024 07:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 5c14cdd and 46680d3.

Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (1)
  • package.json (2 hunks)
Additional comments not posted (2)
package.json (2)

15-15: 新清理脚本更通用

用Node.js脚本清理工作区很棒。这样在所有平台上都能正常运行。


16-17: 脚本更新提高兼容性

postinstallcopy:inject改用Node.js脚本很好。这样在Windows上也能顺利运行了。

package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] None 0 510 B alxndrsn

🚮 Removed packages: npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@onekeyfe/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@protobufjs/[email protected], npm/@substrate/[email protected], npm/@substrate/[email protected], npm/@substrate/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@tamagui/[email protected], npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

@Osiris-Team
Copy link
Author

Is there something left to do?
Not sure because of all the bots commenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants