Skip to content

Commit

Permalink
fix: add disableDefaultIgnoredFiles option (#8398)
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondkmp authored Aug 8, 2024
1 parent 8dabf64 commit 5ab2bee
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-roses-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

add disableDefaultIgnoredFiles option
3 changes: 3 additions & 0 deletions docs/generated/PlatformSpecificBuildOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<p><code id="PlatformSpecificBuildOptions-compression">compression</code> = <code>normal</code> “store” | “normal” | “maximum” | “undefined” - The compression level. If you want to rapidly test build, <code>store</code> can reduce build time significantly. <code>maximum</code> doesn’t lead to noticeable size difference, but increase build time.</p>
</li>
<li>
<p><code id="PlatformSpecificBuildOptions-disableDefaultIgnoredFiles">disableDefaultIgnoredFiles</code> = <code>false</code> Boolean | “undefined” - Whether to exclude all default ignored files(<a href="https://www.electron.build/configuration/contents#files">https://www.electron.build/configuration/contents#files</a>) and options. Defaults to <code>false</code>.</p>
</li>
<li>
<p><code id="PlatformSpecificBuildOptions-files">files</code> The <a href="/configuration/contents#files">files</a> configuration.</p>
</li>
<li>
Expand Down
40 changes: 40 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
"disableDefaultIgnoredFiles": {
"default": false,
"description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
"type": [
"null",
"boolean"
]
},
"electronLanguages": {
"anyOf": [
{
Expand Down Expand Up @@ -2275,6 +2283,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
"disableDefaultIgnoredFiles": {
"default": false,
"description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
"type": [
"null",
"boolean"
]
},
"electronLanguages": {
"anyOf": [
{
Expand Down Expand Up @@ -2905,6 +2921,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
"disableDefaultIgnoredFiles": {
"default": false,
"description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
"type": [
"null",
"boolean"
]
},
"electronLanguages": {
"anyOf": [
{
Expand Down Expand Up @@ -6057,6 +6081,14 @@
"description": "Whether to infer update channel from application version pre-release components. e.g. if version `0.12.1-alpha.1`, channel will be set to `alpha`. Otherwise to `latest`.",
"type": "boolean"
},
"disableDefaultIgnoredFiles": {
"default": false,
"description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
"type": [
"null",
"boolean"
]
},
"electronLanguages": {
"anyOf": [
{
Expand Down Expand Up @@ -6695,6 +6727,14 @@
}
]
},
"disableDefaultIgnoredFiles": {
"default": false,
"description": "Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.",
"type": [
"null",
"boolean"
]
},
"disableSanityCheckAsar": {
"default": false,
"description": "Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export interface PlatformSpecificBuildOptions extends TargetSpecificOptions {
*/
readonly compression?: CompressionLevel | null

/**
* Whether to exclude all default ignored files(https://www.electron.build/configuration/contents#files) and options. Defaults to `false`.
*
* @default false
*/
disableDefaultIgnoredFiles?: boolean | null

files?: Array<FileSet | string> | FileSet | string | null
extraResources?: Array<FileSet | string> | FileSet | string | null
extraFiles?: Array<FileSet | string> | FileSet | string | null
Expand Down
6 changes: 4 additions & 2 deletions packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { CONCURRENCY } from "builder-util"
import { lstat, readdir } from "fs-extra"
import { lstat, readdir, lstatSync } from "fs-extra"
import * as path from "path"
import { excludedNames, FileMatcher } from "../fileMatcher"
import { Packager } from "../packager"
Expand Down Expand Up @@ -76,7 +76,9 @@ export class NodeModuleCopyHelper extends FileCopyHelper {
return null
}

if (!forceIncluded) {
// check if filematcher matches the files array as more important than the default excluded files.
const fileMatched = filter != null && filter(dirPath, lstatSync(dirPath))
if (!fileMatched || !forceIncluded || !!this.packager.config.disableDefaultIgnoredFiles) {
for (const ext of nodeModuleExcludedExts) {
if (name.endsWith(ext)) {
return null
Expand Down

0 comments on commit 5ab2bee

Please sign in to comment.