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

fix: use FileCopier for copying files and queue creation of symlinks #8663

Merged
merged 19 commits into from
Nov 5, 2024

Conversation

mmaietta
Copy link
Collaborator

@mmaietta mmaietta commented Nov 5, 2024

Fixes: #8655

Adds HelloWorld.framework test case (along with build script) to test folder structures containing a plethora of symlinks.
Test case tree structure is below:

/private/var/folders/y3/r1xf5xzn5pddms2gslqh14sh0000gn/T/et-5a873b0a5efb7affcd771efe4ab31bfa/t-uhAANC/test-project-0/dist/linux-arm64-unpacked/resources/app
├── foo.js -> index.js
├── index.js
├── node_modules
│   ├── debug
│   │   ├── LICENSE
│   │   ├── dist
│   │   │   └── debug.js
│   │   ├── package.json
│   │   └── src
│   │       ├── browser.js
│   │       ├── common.js
│   │       ├── index.js
│   │       └── node.js
│   ├── hello-world
│   │   ├── hello-world-framework.sh
│   │   ├── lib
│   │   │   └── Release
│   │   │       └── Hello.framework
│   │   │           ├── Headers -> Versions/Current/Headers
│   │   │           ├── Hello -> Versions/Current/Hello
│   │   │           ├── Info.plist -> Versions/Current/Info.plist
│   │   │           ├── Modules -> Versions/Current/Modules
│   │   │           └── Versions
│   │   │               ├── A
│   │   │               │   ├── Headers
│   │   │               │   │   └── HelloFramework.h
│   │   │               │   ├── Hello
│   │   │               │   ├── Info.plist
│   │   │               │   └── Modules
│   │   │               │       ├── Hello.abi.json
│   │   │               │       ├── Hello.swiftdoc
│   │   │               │       ├── Hello.swiftmodule
│   │   │               │       │   ├── arm64.private.swiftinterface
│   │   │               │       │   ├── arm64.swiftinterface
│   │   │               │       │   ├── arm64.swiftmodule
│   │   │               │       │   ├── x86_64.private.swiftinterface
│   │   │               │       │   ├── x86_64.swiftinterface
│   │   │               │       │   └── x86_64.swiftmodule
│   │   │               │       ├── Hello.swiftsourceinfo
│   │   │               │       └── module.modulemap
│   │   │               └── Current -> A
│   │   └── package.json
│   └── ms
│       ├── index.js
│       ├── license.md
│       └── package.json
└── package.json

Copy link

changeset-bot bot commented Nov 5, 2024

⚠️ No Changeset found

Latest commit: 130a1c2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@mmaietta mmaietta marked this pull request as ready for review November 5, 2024 17:48
beyondkmp
beyondkmp previously approved these changes Nov 5, 2024
@beyondkmp
Copy link
Collaborator

There's another scenario where a symlink points to an empty directory. The actual empty directory probably won't be copied, and then the symlink will throw an error.

In this scenario, should we just delete this kind of symlink without any further processing?

@mmaietta
Copy link
Collaborator Author

mmaietta commented Nov 5, 2024

Great callout @beyondkmp , looks like that issue is pre-existing elsewhere in the codebase
I added a Resources symlink to an empty directory and received this error. That's a separate issue from the electron/asar changes AFAICT though since it's before the asar packaging step

    ENOENT: no such file or directory, stat '/tmp/et-db411cd21f3bbd882f3a5a30c58db6ff/t-dVdcd3/test-project-0/hello-world/lib/Release/Hello.framework/Resources'

      169 |
      170 |     for (const [file, index] of symlinkFiles) {
    > 171 |       const resolvedPath = realpathSync(file)
          |                                        ^
      172 |       if (emptyDirs.has(resolvedPath)) {
      173 |         // delete symlink file if target is a empty dir
      174 |         result[index] = undefined

      at NodeModuleCopyHelper.collectNodeModules (../packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts:171:40)
      at collectNodeModules (../packages/app-builder-lib/src/util/appFileCopier.ts:195:19)
      at computeNodeModuleFileSets (../packages/app-builder-lib/src/util/appFileCopier.ts:207:5)

The folder tree:

test/fixtures/test-app-symlink-framework/hello-world/lib/Release
└── Hello.framework
    ├── Headers -> Versions/Current/Headers
    ├── Hello -> Versions/Current/Hello
    ├── Info.plist -> Versions/Current/Info.plist
    ├── Modules -> Versions/Current/Modules
    ├── Resources -> Versions/Current/Resources
    └── Versions
        ├── A
        │   ├── Headers
        │   │   └── HelloFramework.h
        │   ├── Hello
        │   ├── Info.plist
        │   ├── Modules
        │   │   ├── Hello.abi.json
        │   │   ├── Hello.swiftdoc
        │   │   ├── Hello.swiftmodule
        │   │   │   ├── arm64.private.swiftinterface
        │   │   │   ├── arm64.swiftinterface
        │   │   │   ├── arm64.swiftmodule
        │   │   │   ├── x86_64.private.swiftinterface
        │   │   │   ├── x86_64.swiftinterface
        │   │   │   └── x86_64.swiftmodule
        │   │   ├── Hello.swiftsourceinfo
        │   │   └── module.modulemap
        │   └── Resources
        └── Current -> A

12 directories, 15 files

@mmaietta mmaietta merged commit 866b0ca into master Nov 5, 2024
13 checks passed
@mmaietta mmaietta deleted the fix/file-copier-symlink branch November 5, 2024 22:24
@mmaietta mmaietta restored the fix/file-copier-symlink branch November 5, 2024 22:24
@mmaietta mmaietta deleted the fix/file-copier-symlink branch November 5, 2024 22:26
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.

electron builder v26.0.0-alpha.2 fails to copy native deps with sym links
2 participants