Skip to content

Commit

Permalink
fix: add additional default exclusions (node_gyp_bins, `pnpm-lock.y…
Browse files Browse the repository at this point in the history
…aml`, `.obj`) to copy logic (#8577)
  • Loading branch information
mmaietta authored Oct 9, 2024
1 parent 515a1d5 commit e9eef0c
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-tigers-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix: add additional default exclusions to copy logic
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/fileMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export const excludedNames =
".git,.hg,.svn,CVS,RCS,SCCS," +
"__pycache__,.DS_Store,thumbs.db,.gitignore,.gitkeep,.gitattributes,.npmignore," +
".idea,.vs,.flowconfig,.jshintrc,.eslintrc,.circleci," +
".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log," +
".yarn-integrity,.yarn-metadata.json,yarn-error.log,yarn.lock,package-lock.json,npm-debug.log,pnpm-lock.yaml," +
"appveyor.yml,.travis.yml,circle.yml,.nyc_output,.husky,.github,electron-builder.env"

export const excludedExts =
"iml,hprof,orig,pyc,pyo,rbc,swp,csproj,sln,suo,xproj,cc,d.ts," +
// /~https://github.com/electron-userland/electron-builder/issues/7512
"mk,a,o,forge-meta"
"mk,a,o,obj,forge-meta"

function ensureNoEndSlash(file: string): string {
if (path.sep !== "/") {
Expand Down
17 changes: 13 additions & 4 deletions packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ import { NodeModuleInfo } from "./packageDependencies"
import { realpathSync } from "fs"

const excludedFiles = new Set(
[".DS_Store", "node_modules" /* already in the queue */, "CHANGELOG.md", "ChangeLog", "changelog.md", "Changelog.md", "Changelog", "binding.gyp", ".npmignore"].concat(
excludedNames.split(",")
)
)
[
".DS_Store",
"node_modules" /* already in the queue */,
"CHANGELOG.md",
"ChangeLog",
"changelog.md",
"Changelog.md",
"Changelog",
"binding.gyp",
".npmignore",
"node_gyp_bins",
].concat(excludedNames.split(",")))

Check warning on line 24 in packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts

View workflow job for this annotation

GitHub Actions / test-linux (ArtifactPublisherTest,BuildTest,ExtraBuildTest,RepoSlugTest,binDownloadTest,configura...

Insert `⏎`

Check warning on line 24 in packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts

View workflow job for this annotation

GitHub Actions / test-linux (snapTest,debTest,fpmTest,protonTest)

Insert `⏎`

const topLevelExcludedFiles = new Set([
"karma.conf.js",
".coveralls.yml",
Expand Down
9 changes: 0 additions & 9 deletions test/snapshots/HoistedNodeModuleTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,6 @@ Object {
},
"unpacked": true,
},
"node_gyp_bins": Object {
"files": Object {
"python3": Object {
"size": 5490456,
"unpacked": true,
},
},
"unpacked": true,
},
},
},
"deps": Object {
Expand Down
48 changes: 42 additions & 6 deletions test/snapshots/globTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9816,12 +9816,27 @@ Object {
"files": Object {
"assets": Object {
"files": Object {
"file": Object {
"file-symlink2": Object {
"link": "assets/file2",
},
"file1": Object {
"size": 4,
"unpacked": true,
},
"file2": Object {
"size": 4,
"unpacked": true,
},
"file-symlink": Object {
"link": "assets/file",
"subdir": Object {
"files": Object {
"file-symlink1": Object {
"link": "assets/file1",
},
"file3": Object {
"size": 4,
"unpacked": true,
},
},
},
},
},
Expand Down Expand Up @@ -9861,6 +9876,9 @@ Object {
},
},
},
"file-symlink3": Object {
"link": "assets/subdir/file3",
},
"index.html": Object {
"offset": "4",
"size": 378,
Expand Down Expand Up @@ -9912,12 +9930,27 @@ Object {
},
"assets": Object {
"files": Object {
"file": Object {
"file-symlink2": Object {
"link": "assets/file2",
},
"file1": Object {
"size": 4,
"unpacked": true,
},
"file2": Object {
"size": 4,
"unpacked": true,
},
"file-symlink": Object {
"link": "assets/file",
"subdir": Object {
"files": Object {
"file-symlink1": Object {
"link": "assets/file1",
},
"file3": Object {
"size": 4,
"unpacked": true,
},
},
},
},
},
Expand Down Expand Up @@ -9957,6 +9990,9 @@ Object {
},
},
},
"file-symlink3": Object {
"link": "assets/subdir/file3",
},
"index.html": Object {
"offset": "114",
"size": 841,
Expand Down
24 changes: 24 additions & 0 deletions test/snapshots/ignoreTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,36 @@ Object {
}
`;

exports[`Don't copy sub node_modules of the other dir instead of rootDir 1`] = `
Object {
"linux": Array [],
}
`;

exports[`cannot copied select submodule node_modules by **/submodule-1-test/node_modules 1`] = `
Object {
"linux": Array [],
}
`;

exports[`cannot copied select submodule node_modules by */ 1`] = `
Object {
"linux": Array [],
}
`;

exports[`copied select submodule node_modules 1`] = `
Object {
"linux": Array [],
}
`;

exports[`copied sub node_modules of the rootDir/node_modules 1`] = `
Object {
"linux": Array [],
}
`;

exports[`ignore build resources 1`] = `
Object {
"linux": Array [],
Expand Down
18 changes: 0 additions & 18 deletions test/snapshots/mac/macPackagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,6 @@ Object {
},
},
},
"node_gyp_bins": Object {
"files": Object {
"python3": Object {
"size": "<size>",
"unpacked": true,
},
},
},
},
},
"index.js": Object {
Expand Down Expand Up @@ -776,14 +768,6 @@ Object {
},
},
},
"node_gyp_bins": Object {
"files": Object {
"python3": Object {
"size": "<size>",
"unpacked": true,
},
},
},
},
},
"deps": Object {
Expand Down Expand Up @@ -1672,7 +1656,6 @@ Array [
"app.asar.unpacked/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt",
"app.asar.unpacked/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Results.txt",
"app.asar.unpacked/node_modules/node-pty/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt",
"app.asar.unpacked/node_modules/node-pty/build/node_gyp_bins/python3",
"app.asar.unpacked/node_modules/node-pty/build/Release/pty.node",
"app.asar.unpacked/node_modules/node-pty/build/Release/spawn-helper",
"app.asar.unpacked/node_modules/node-mac-permissions/LICENSE",
Expand Down Expand Up @@ -1719,7 +1702,6 @@ Array [
"name": "app.asar.unpacked/node_modules/node-mac-permissions/package.json",
},
"app.asar.unpacked/node_modules/node-mac-permissions/permissions.mm",
"app.asar.unpacked/node_modules/node-mac-permissions/build/node_gyp_bins/python3",
"app.asar.unpacked/node_modules/node-mac-permissions/build/Release/permissions.node",
]
`;
8 changes: 6 additions & 2 deletions test/src/globTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { verifySmartUnpack } from "./helpers/verifySmartUnpack"

async function createFiles(appDir: string) {
await Promise.all([
outputFile(path.join(appDir, "assets", "file"), "data"),
outputFile(path.join(appDir, "assets", "file1"), "data"),
outputFile(path.join(appDir, "assets", "file2"), "data"),
outputFile(path.join(appDir, "assets", "subdir", "file3"), "data"),
outputFile(path.join(appDir, "b2", "file"), "data"),
outputFile(path.join(appDir, "do-not-unpack-dir", "file.json"), "{}").then(() => fs.writeFile(path.join(appDir, "do-not-unpack-dir", "must-be-not-unpacked"), "{}")),
])
Expand All @@ -18,7 +20,9 @@ async function createFiles(appDir: string) {
await fs.mkdir(dir, { recursive: true })
await fs.writeFile(path.join(dir, "file-in-asar"), "{}")

await fs.symlink(path.join(appDir, "assets", "file"), path.join(appDir, "assets", "file-symlink"))
await fs.symlink(path.join(appDir, "assets", "file1"), path.join(appDir, "assets", "subdir", "file-symlink1")) // "reverse" symlink up one directory
await fs.symlink(path.join(appDir, "assets", "file2"), path.join(appDir, "assets", "file-symlink2")) // same dir symlink
await fs.symlink(path.join(appDir, "assets", "subdir", "file3"), path.join(appDir, "file-symlink3")) // symlink down
}

test.ifNotWindows.ifDevOrLinuxCi(
Expand Down

0 comments on commit e9eef0c

Please sign in to comment.