Skip to content

feat: add support for loong64 arch and openharmony platform#56

Merged
JounQin merged 2 commits intomainfrom
feat/loong64_and_openharmony
Oct 4, 2025
Merged

feat: add support for loong64 arch and openharmony platform#56
JounQin merged 2 commits intomainfrom
feat/loong64_and_openharmony

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Oct 4, 2025

close #42


Important

Add support for loong64 architecture and openharmony platform in helpers.ts, target.ts, and types.ts.

  • Behavior:
    • Add support for loong64 architecture in getNapiNativeTarget() in helpers.ts.
    • Add support for openharmony platform in getNapiNativeTarget() in helpers.ts.
  • Platform Parsing:
    • Update parseTriple() in target.ts to handle loongarch64 and ohos as loong64 and openharmony respectively.
  • Types:
    • Add openharmony to Platform type in types.ts.

This description was created by Ellipsis for 7f9959f. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Added OpenHarmony platform support across target detection and mapping.
    • Added LoongArch (loong64) architecture support with musl/gnu selection on Linux.
    • Improved Windows x64 target resolution to include MinGW when detected.
    • Enhanced triple parsing to treat Android and OpenHarmony as subsystems for accurate platform/ABI mapping.
  • Chores

    • Added changeset entry for the patch/feature release.

@changeset-bot
Copy link

changeset-bot bot commented Oct 4, 2025

🦋 Changeset detected

Latest commit: 3ba2f42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
napi-postinstall Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Walkthrough

Adds OpenHarmony platform and LoongArch (loong64) support across types, triple parsing, and native-target resolution; normalizes subsystem ABIs (android/ohos) during parseTriple; Windows x64 resolution can return multiple candidates (MINGW → GNU then MSVC); Linux loong64 splits musl/gnu.

Changes

Cohort / File(s) Summary
Type updates
src/types.ts
Expands Platform type to include 'openharmony' and fixes minor JSDoc typo.
Target parsing logic
src/target.ts
Adds LoongArch mapping (loongarch64loong64), maps ohosopenharmony, introduces SUB_SYSTEMS (android, ohos) and normalizes triples so subsystem ABIs are treated as platforms (sets abi = null).
Native target resolution
src/helpers.ts
Casts process.platform to Platform; Windows x64 now returns candidate array with conditional 'win32-x64-gnu' for MINGW before 'win32-x64-msvc'; adds Linux loong64 musl/gnu split; adds OpenHarmony target mappings for arm/arm64/x64; integrates Linux loong64 case and finalizes switch logic.
Changelog / changeset
.changeset/cuddly-doors-add.md
Adds a changeset noting patch and feature: loong64 and OpenHarmony support.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Parser as parseTriple
  participant Subsys as Subsystem Normalizer
  participant Resolver as getNapiNativeTarget
  participant Env as OS/Env

  Client->>Parser: parseTriple(rawTriple)
  Parser->>Subsys: check abi in {android, ohos}
  alt abi is subsystem
    Note over Subsys: promote abi -> platform\nset abi = null
  else
    Note over Subsys: keep abi/platform
  end
  Parser-->>Client: normalized {platform, arch, abi}

  Client->>Resolver: resolve targets(platform, arch)
  alt platform == win32 and arch == x64
    Env-->>Resolver: detect shell (MINGW?)
    alt MINGW
      Resolver-->>Client: ["win32-x64-gnu", "win32-x64-msvc"]
    else
      Resolver-->>Client: ["win32-x64-msvc"]
    end
  else platform == linux and arch == loong64
    Env-->>Resolver: isMusl()?
    alt musl
      Resolver-->>Client: ["linux-loong64-musl"]
    else
      Resolver-->>Client: ["linux-loong64-gnu"]
    end
  else platform == openharmony
    Resolver-->>Client: ["openharmony-arm", "openharmony-arm64", "openharmony-x64"]
  else
    Resolver-->>Client: [existing targets]
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement, feature

Poem

A rabbit taps the build drums slow,
Loong winds whisper: loong64 in tow.
Windows sings GNU then MSVC cheer,
OpenHarmony hops now near.
Triples trimmed — the targets grow! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request introduces loong64 architecture support alongside the OpenHarmony updates, which falls outside the scope of the linked issue #42 that focuses solely on ohos platform synchronization. Please extract the loong64 architecture changes into a separate pull request or limit this one to the OpenHarmony support requested by issue #42.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately describes the main change by highlighting the added support for the loong64 architecture and the OpenHarmony platform, matching the PR’s objectives.
Linked Issues Check ✅ Passed The pull request fully implements the requested OpenHarmony (ohos) support by updating helpers.ts, target.ts, and types.ts to recognize and map ohos to openharmony as specified in issue #42.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/loong64_and_openharmony

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f9959f and 3ba2f42.

📒 Files selected for processing (1)
  • .changeset/cuddly-doors-add.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/cuddly-doors-add.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 24 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-1.07% (target: -1.00%) 17.14%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2b6c5c0) 710 278 39.15%
Head commit (7f9959f) 743 (+33) 283 (+5) 38.09% (-1.07%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#56) 35 6 17.14%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

1 similar comment
@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-1.07% (target: -1.00%) 17.14%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2b6c5c0) 710 278 39.15%
Head commit (7f9959f) 743 (+33) 283 (+5) 38.09% (-1.07%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#56) 35 6 17.14%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@codecov
Copy link

codecov bot commented Oct 4, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.79%. Comparing base (2b6c5c0) to head (3ba2f42).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/helpers.ts 7.14% 26 Missing ⚠️
src/target.ts 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #56      +/-   ##
==========================================
- Coverage   39.74%   38.79%   -0.96%     
==========================================
  Files           7        7              
  Lines         712      745      +33     
  Branches       69       70       +1     
==========================================
+ Hits          283      289       +6     
- Misses        429      456      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 4, 2025

Open in StackBlitz

npm i https://pkg.pr.new/napi-postinstall@56

commit: 3ba2f42

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 7f9959f in 56 seconds. Click for details.
  • Reviewed 176 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/helpers.ts:7
  • Draft comment:
    Added 'Platform' type to the import for type consistency.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. src/helpers.ts:175
  • Draft comment:
    Casting process.platform as Platform ensures support for extended platform values.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. src/helpers.ts:187
  • Draft comment:
    Win32 branch now returns an array including 'win32-x64-gnu' for MINGW systems. Consider checking if process.report.getReport() exists to avoid runtime errors in environments where it's unavailable.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. src/helpers.ts:236
  • Draft comment:
    Added loong64 architecture support; ensure that the isMusl detection works reliably on Loongarch systems.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. src/helpers.ts:270
  • Draft comment:
    Added openharmony platform branch; verify that the process.arch checks and returned target strings are correct for the environment.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
6. src/target.ts:11
  • Draft comment:
    Added mapping for 'loongarch64' to 'loong64' in CpuToNodeArch, ensuring consistency with the loong64 support in helpers.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
7. src/target.ts:21
  • Draft comment:
    Mapping 'ohos' to 'openharmony' in SysToNodePlatform normalizes legacy platform strings.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
8. src/target.ts:24
  • Draft comment:
    Including 'ohos' in the SUB_SYSTEMS set helps handle subsystem overrides in triple parsing.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
9. src/target.ts:26
  • Draft comment:
    Improved triple documentation formatting enhances clarity on how triples are structured.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
10. src/types.ts:3
  • Draft comment:
    Fixed typos in deprecation comments (e.g., 'USe' to 'Use') to improve documentation clarity.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_ElDA38yQUCT7AJkN

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2025

📊 Package size report   3%↑

File Before After
lib/helpers.js 7.4 kB 11%↑8.2 kB
lib/helpers.js.map 6.6 kB 10%↑7.2 kB
lib/target.js 1.6 kB 12%↑1.8 kB
lib/target.js.map 1.5 kB 15%↑1.7 kB
lib/types.d.ts 825 B 2%↑841 B
Total (Includes all files) 60.6 kB 3%↑62.4 kB
Tarball size 16.4 kB 2%↑16.7 kB
Unchanged files
File Size
lib/cli.d.ts 31 B
lib/cli.js 985 B
lib/cli.js.map 902 B
lib/constants.d.ts 417 B
lib/constants.js 703 B
lib/constants.js.map 519 B
lib/fallback.d.ts 111 B
lib/fallback.js 3.2 kB
lib/fallback.js.map 3.1 kB
lib/helpers.d.ts 846 B
lib/index.d.ts 415 B
lib/index.js 10.5 kB
lib/index.js.map 9.1 kB
lib/target.d.ts 106 B
lib/types.js 110 B
lib/types.js.map 102 B
LICENSE 1.1 kB
package.json 3.6 kB
README.md 6.7 kB

🤖 This report was automatically generated by pkg-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2025

Deploy preview for napi-postinstall ready!

✅ Preview
https://napi-postinstall-6y5e4r81q-1stg.vercel.app

Built with commit 3ba2f42.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2025

size-limit report 📦

Path Size
lib/index.js 2.46 KB (0%)

@codacy-production
Copy link

codacy-production bot commented Oct 4, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-1.07% (target: -1.00%) 17.14%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2b6c5c0) 710 278 39.15%
Head commit (3ba2f42) 743 (+33) 283 (+5) 38.09% (-1.07%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#56) 35 6 17.14%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Signed-off-by: JounQin <admin@1stg.me>
@JounQin JounQin merged commit 9ce741b into main Oct 4, 2025
39 of 42 checks passed
@JounQin JounQin deleted the feat/loong64_and_openharmony branch October 4, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sync ohos support

1 participant