Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: packages in the workspace not being under node_modules #8576

Merged
merged 12 commits into from
Oct 10, 2024

Conversation

beyondkmp
Copy link
Collaborator

@beyondkmp beyondkmp commented Oct 9, 2024

fix develar/app-builder#141

reproduced error info

  ● yarn several workspaces

    /tmp/et-db411cd21f3bbd882f3a5a30c58db6ff/t-kIKFAh/test-project-2/packages/foo/package.json must be under /tmp/et-db411cd21f3bbd882f3a5a30c58db6ff/t-kIKFAh/test-project-2/packages/test-app/

      30 |     const index = file.indexOf(NODE_MODULES_PATTERN)
      31 |     if (index < 0) {
    > 32 |       throw new Error(`${file} must be under ${srcWithEndSlash}`)
         |             ^
      33 |     } else {
      34 |       return file.substring(index + 1 /* leading slash */)
      35 |     }

      at getRelativePath (../packages/app-builder-lib/src/util/filter.ts:32:13)
      at AsarPackager.unpackPattern (../packages/app-builder-lib/src/util/filter.ts:57:20)
      at AsarPackager.createPackageFromFiles (../packages/app-builder-lib/src/asar/asarUtil.ts:129:82)
      at AsarPackager.pack (../packages/app-builder-lib/src/asar/asarUtil.ts:49:41)
      at ../packages/app-builder-lib/src/platformPackager.ts:439:11
          at async Promise.all (index 0)
      at AsyncTaskManager.awaitTasks (../packages/builder-util/src/asyncTaskManager.ts:65:25)
      at LinuxPackager.doPack (../packages/app-builder-lib/src/platformPackager.ts:293:5)
      at LinuxPackager.pack (../packages/app-builder-lib/src/platformPackager.ts:138:5)
      at Packager.doBuild (../packages/app-builder-lib/src/packager.ts:459:9)
      at executeFinally (../packages/builder-util/src/promise.ts:12:14)
      at Packager.build (../packages/app-builder-lib/src/packager.ts:393:31)
      at packAndCheck (src/helpers/packTester.ts:188:41)
      at src/helpers/packTester.ts:132:36
      at executeFinally (../packages/builder-util/src/promise.ts:12:14)

Currently, the returned node_modules paths are no longer symlinks, but resolved paths. For example, packages in pnpm workspace/yarn workspace are not under node_modules.

All previous getRealSource/getRelativePath methods were based on node_modules in the path, which was relatively tricky.

const getRealSource = (name: string, source: string) => {
let parentDir = path.dirname(source)
const scopeDepth = name.split("/").length
// get the parent dir of the package, input: /root/path/node_modules/@electron/remote, output: /root/path/node_modules
for (let i = 0; i < scopeDepth - 1; i++) {
parentDir = path.dirname(parentDir)
}
// for the local node modules which is not in node modules
if (!parentDir.endsWith(path.sep + NODE_MODULES)) {
return parentDir
}

function getRelativePath(file: string, srcWithEndSlash: string) {
if (!file.startsWith(srcWithEndSlash)) {
const index = file.indexOf(NODE_MODULES_PATTERN)
if (index < 0) {
throw new Error(`${file} must be under ${srcWithEndSlash}`)
} else {
return file.substring(index + 1 /* leading slash */)
}
}

Solution: Directly include relativeNodeModulesPath in the file stats. This is simple and easy to understand.

Copy link

changeset-bot bot commented Oct 9, 2024

🦋 Changeset detected

Latest commit: a2871a1

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

This PR includes changesets to release 10 packages
Name Type
app-builder-lib Patch
builder-util Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch
electron-publish 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

@beyondkmp beyondkmp marked this pull request as draft October 9, 2024 13:50
Copy link

netlify bot commented Oct 9, 2024

Deploy Preview for car-park-attendant-cleat-11576 ready!

Name Link
🔨 Latest commit a2871a1
🔍 Latest deploy log https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/6707e7a0553b770008cca2eb
😎 Deploy Preview https://deploy-preview-8576--car-park-attendant-cleat-11576.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@beyondkmp beyondkmp marked this pull request as ready for review October 9, 2024 14:40
@beyondkmp beyondkmp requested a review from mmaietta October 9, 2024 14:40
@beyondkmp beyondkmp changed the title fix: workspace asarupack issue fix: packages in the workspace not being under node_modules Oct 9, 2024
@beyondkmp beyondkmp merged commit 3eab714 into electron-userland:master Oct 10, 2024
13 checks passed
@beyondkmp beyondkmp deleted the workspace branch October 10, 2024 16:33
mmaietta pushed a commit that referenced this pull request Jan 26, 2025
## 26.0.0

### Major Changes

-
[#8782](#8782)
[`633490cb`](633490c)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: removing
conditional logic that would build HFS+ dmg on non-arm64 macs as HFS+
was sunset in macos 15.2
-
[#8582](#8582)
[`6a9597b4`](6a9597b)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore: remove
deprecated fields from `winOptions` and `macOptions`. (For `winOptions`
signing configuration, it has been moved to `win.signtoolOptions` in
order to support `azureOptions` as a separate field and avoid bloating
`win` configuration object. For `macOptions`, notarize options has been
deprecated in favor of env vars for quite some time. Env vars are much
more secure)
-
[#8572](#8572)
[`0dbe357a`](0dbe357)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: allowing
additional entries in .desktop file, such as `[Desktop Actions
<actionName>]`. Requires changing configuration `desktop` property to
object to be more extensible in the future
-
[#8562](#8562)
[`b8185d48`](b8185d4)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - support including
node_modules in other subdirectories

### Minor Changes

-
[#8787](#8787)
[`cdf18d9a`](cdf18d9)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: add `pwsh`
detection to enable azure trusted signing within docker image
-
[#8711](#8711)
[`6f0fb8e4`](6f0fb8e)
Thanks [@hrueger](https://github.com/hrueger)! - Add `host` property to
support self-hosted Keygen instances
-
[#8636](#8636)
[`88cc0b06`](88cc0b0)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: add support for
AppArmor with template profile and configuration property
-
[#8609](#8609)
[`d672b04b`](d672b04)
Thanks [@iongion](https://github.com/iongion)! - feat: support
completely custom AppxManifest.xml
-
[#8607](#8607)
[`f123628c`](f123628)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: allow disabling
of building a universal windows installer
-
[#8588](#8588)
[`8434e10d`](8434e10)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: adding
integration with @electron/fuses
-
[#8570](#8570)
[`c8484305`](c848430)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: migrate to
official `electron/asar` packaging
-
[#8525](#8525)
[`13f55a3e`](13f55a3)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat: migrate
`electronDist` to be an electron-builder `Hook`
-
[#8394](#8394)
[`ae9221d9`](ae9221d)
Thanks [@xyloflake](https://github.com/xyloflake)! - feat: Implement
autoupdates for pacman
-
[#8741](#8741)
[`eacbbf59`](eacbbf5)
Thanks [@0xlau](https://github.com/0xlau)! - Add `forcePathStyle` option
to S3Options

### Patch Changes
-
[#8575](#8575)
[`dfa35c32`](dfa35c3)
Thanks [@doctolivier](https://github.com/doctolivier)! - chore(deps):
update @electron/rebuild to v3.7.0
-
[#8576](#8576)
[`3eab7143`](3eab714)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix: packages in
the workspace not being under node_modules
-
[#8577](#8577)
[`e9eef0c1`](e9eef0c)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: add additional
default exclusions to copy logic
-
[#8596](#8596)
[`e0b0e351`](e0b0e35)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore: refactor files
for publishing to electron-publish
-
[#8601](#8601)
[`215fc36b`](215fc36)
Thanks [@mmaietta](https://github.com/mmaietta)! - Revert "fix(win): use
appInfo description as primary entry for FileDescription" to resolve
[#8599](#8599)
-
[#8603](#8603)
[`712a8bce`](712a8bc)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: checking
relative path without separator as that doesn't work on Windows
-
[#8604](#8604)
[`d4ea0d99`](d4ea0d9)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - chore(deps): update
app-builder-bin to 5.0.0-alpha.11
-
[#8606](#8606)
[`a0e635c1`](a0e635c)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: add quotes to
surround file path during azure signing to handle files with spaces
-
[#8627](#8627)
[`2a3195d9`](2a3195d)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: add rfc3161
timestamp entry as default for azure signing to resolve Windows Defender
alert
-
[#8631](#8631)
[`dcd91a1f`](dcd91a1)
Thanks [@olivereisenhut](https://github.com/olivereisenhut)! - fix:
Remove path from published binaries
-
[#8632](#8632)
[`645e2abd`](645e2ab)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: only sign
concurrently when using local signtool. azure can't be in parallel due
to resources being locked during usage
-
[#8637](#8637)
[`667ab2f8`](667ab2f)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore: migrate
default recommends and default depends for fpm from app-builder-bin to
JS code
-
[#8645](#8645)
[`f4d40f91`](f4d40f9)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix: smart unpack
for local module with dll
-
[#8653](#8653)
[`796e1a07`](796e1a0)
Thanks [@IsaacAderogba](https://github.com/IsaacAderogba)! - fix:
cscIKeyPassword must support empty string arguments
-
[#8654](#8654)
[`9e11358f`](9e11358)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: check
ResolvedFileSet src when verifying symlinks to be within project
directory
-
[#8661](#8661)
[`6a294c97`](6a294c9)
Thanks [@t3chguy](https://github.com/t3chguy)! - chore: remove stale
handler for `extend-info` in electronMac plist creation
-
[#8689](#8689)
[`1d7f87c1`](1d7f87c)
Thanks [@Lemonexe](https://github.com/Lemonexe)! - fix(win): corrupt
asar integrity file path on crossplatform build
-
[#8693](#8693)
[`6a6bed46`](6a6bed4)
Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps):
update dependency cross-spawn to v7.0.5 [security]
-
[#8714](#8714)
[`66334502`](6633450)
Thanks [@kttmv](https://github.com/kttmv)! - chore: Remove informal
Russian messages in the NSIS installer
-
[#8715](#8715)
[`4c394d54`](4c394d5)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix: does not work
with NPM workspaces
-
[#8717](#8717)
[`9381513d`](9381513)
Thanks [@beyondkmp](https://github.com/beyondkmp)! - fix(deps): update
dependency eslint to v9.16.0 [security]
-
[#8783](#8783)
[`a5558e33`](a5558e3)
Thanks [@mmaietta](https://github.com/mmaietta)! - chore(deps): upgrade
cross spawn 7.0.6
-
[#8805](#8805)
[`c6d6b6e5`](c6d6b6e)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: ASAR files in
extraResources are not included in integrity calculations
-
[`a1ee0419`](a1ee041)
Thanks [@mmaietta](https://github.com/mmaietta)! - fix: use FileCopier
for copying files and queue creation of symlinks

## electron-updater 6.4.0

### Minor Changes

-
[#8711](#8711)
[`6f0fb8e4`](6f0fb8e)
Thanks [@hrueger](https://github.com/hrueger)! - Add `host` property to
support self-hosted Keygen instances
-
[#8633](#8633)
[`96f5c3eb`](96f5c3e)
Thanks [@mmaietta](https://github.com/mmaietta)! - feat(updater): allow
usage of `autoRunAppAfterInstall` on mac updater
-
[#8394](#8394)
[`ae9221d9`](ae9221d)
Thanks [@xyloflake](https://github.com/xyloflake)! - feat: Implement
autoupdates for pacman

### Patch Changes

-
[#8802](#8802)
[`4a68fd2d`](4a68fd2)
Thanks [@erijo](https://github.com/erijo)! - fix(linux): AppImage update
fails when filename contains spaces
-
[#8623](#8623)
[`cfa67c01`](cfa67c0)
Thanks [@DamonYu6](https://github.com/DamonYu6)! - fix: copyFileSync
operation will block the main thread
-
[#8695](#8695)
[`819eff7b`](819eff7)
Thanks [@peter-sanderson](https://github.com/peter-sanderson)! - fix:
respect `disableDifferentialDownload` flag for AppImage
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make symlink behavior configurable
2 participants