Skip to content

feat: add AppScope support, switch to commonjs#13

Open
Groupguanfang wants to merge 3 commits intomainfrom
naily-dev
Open

feat: add AppScope support, switch to commonjs#13
Groupguanfang wants to merge 3 commits intomainfrom
naily-dev

Conversation

@Groupguanfang
Copy link
Contributor

No description provided.

@Groupguanfang Groupguanfang self-assigned this Dec 9, 2025
Copilot AI review requested due to automatic review settings December 9, 2025 10:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds AppScope support to the project detector library and migrates from ESM (ES modules) to CommonJS module format.

Key Changes:

  • Introduces a new AppScope struct and API for handling HarmonyOS app-level configuration
  • Refactors reference handling throughout the Rust codebase to use Rc<Reference<T>> for better memory management
  • Converts module system from ESM to CommonJS (type: "module" removed, exports changed)

Reviewed changes

Copilot reviewed 29 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/rust/app_scope.rs New AppScope implementation for app.json5 configuration handling
src/rust/resource.rs Added ResourceType enum and AppScope integration with Resource
src/rust/resource_directory.rs Improved reference cloning with Rc wrapper
src/rust/project.rs Refactored to use Rc for ProjectDetector references
src/rust/product.rs Updated Module reference handling with Rc
src/rust/module.rs Improved Project reference cloning patterns
src/rust/utils/qualifier/utils_impl.rs Converted block comments to doc comments with TypeScript type hints
src/rust/references/element_json_file_reference.rs Enhanced error handling for parser operations
src/node/app-scope.ts TypeScript wrapper for AppScope with signal-based reactivity
index.js Converted from ESM to CommonJS exports
package.json Removed "type": "module" and updated build command
test/node.spec.ts Added comprehensive tests for AppScope functionality
Mock data files Added AppScope test fixtures for both harmony projects

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (project.getBuildProfileUri().isEqual(uri) || project.getUri().isEqual(uri)) {
appScope(RustAppScope.from(project.getUnderlyingProject()))
}
else if (uri.fsPath.endsWith('app.json5')) {
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The comparison uri.fsPath.endsWith('app.json5') is fragile and could match unintended files. Consider using a more robust check that ensures the file is specifically in the AppScope directory, such as checking the full path or using uri.isEqual() with the expected app.json5 URI.

Suggested change
else if (uri.fsPath.endsWith('app.json5')) {
else if (uri.isEqual(project.getAppJson5Uri())) {

Copilot uses AI. Check for mistakes.
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.

2 participants