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

feat: switch app-builder-bin to node-module-collector to get all production node modules #8571

Open
wants to merge 112 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
8a34240
switch app-builder-bin to node-module-collector
Oct 4, 2024
f438899
fix ut
Oct 4, 2024
8523bfd
fix ut
Oct 4, 2024
5748dff
fix ut
Oct 4, 2024
150f031
delete ut
Oct 4, 2024
3c38a9e
fix ut
Oct 4, 2024
4e10883
fix ut
Oct 4, 2024
4ea2d53
fix ut
Oct 4, 2024
257b603
update ut
Oct 4, 2024
601bef9
update node modules collector
Oct 4, 2024
2b051a0
fix ut
Oct 4, 2024
b0ef651
update gitinore
Oct 4, 2024
c9c4071
update
Oct 4, 2024
352f08e
update yarn.lock
Oct 4, 2024
f7d91c6
update gitinogre
Oct 4, 2024
2453a15
fix ut
Oct 4, 2024
6823a87
update
Oct 4, 2024
aafd1be
fix ut
Oct 4, 2024
59aa878
fix ut
beyondkmp Oct 4, 2024
c571825
fix ut
Oct 4, 2024
24dbf44
use detect
Oct 5, 2024
1b8cc02
format code
Oct 5, 2024
98021d1
format code
Oct 5, 2024
5bff81b
fix ut
Oct 5, 2024
6da8b0a
fix ut
Oct 5, 2024
69e827a
update to 1.1.4
Oct 5, 2024
accaf6a
fix others submodule filter
beyondkmp Oct 6, 2024
fdb9dd0
add ut
Oct 6, 2024
4f0d78a
format code
Oct 6, 2024
14efc3a
format code
Oct 6, 2024
aca68c2
fix ut
Oct 6, 2024
8b1e1e2
format code
Oct 6, 2024
8bf110d
fix ut
Oct 6, 2024
32d6156
fix ut
Oct 6, 2024
a22668e
add excludeNodMoules
Oct 6, 2024
40df716
fix ut
Oct 6, 2024
5a2e5c5
fix ut
Oct 6, 2024
9d363a8
fix ut
Oct 6, 2024
ceef74c
fix ut
Oct 6, 2024
861f234
add ut
Oct 6, 2024
e2c7981
fix ut
Oct 6, 2024
e39e6d8
add ut
Oct 6, 2024
127857d
Merge branch 'master' into nodeModulesCollector
Oct 6, 2024
97cdc2d
Merge branch 'excludeNodemoudles' into nodeModulesCollector
Oct 6, 2024
e053855
revert some changes
Oct 6, 2024
2a968f9
delete the obsolete snapshot
Oct 6, 2024
56a9d1e
Merge branch 'master' into nodeModulesCollector
Oct 7, 2024
0a31869
madd node-module-collector
beyondkmp Oct 8, 2024
09cdecd
update lock file
beyondkmp Oct 8, 2024
1227c00
format code
beyondkmp Oct 8, 2024
600958c
format code
beyondkmp Oct 8, 2024
ce21b41
format code
beyondkmp Oct 8, 2024
42bafe1
format code
beyondkmp Oct 8, 2024
f30f7a4
format code
beyondkmp Oct 8, 2024
6956efc
format code
beyondkmp Oct 8, 2024
29c5d01
fix comments
beyondkmp Oct 9, 2024
81db133
fix ut
beyondkmp Oct 9, 2024
fcbe203
update ut
beyondkmp Oct 9, 2024
b6b7540
fix ut
beyondkmp Oct 9, 2024
8715743
fix ut
beyondkmp Oct 9, 2024
94af9fb
format code
beyondkmp Oct 9, 2024
aca36e1
format code
beyondkmp Oct 9, 2024
ce2dfb5
update ignore
beyondkmp Oct 9, 2024
b2b72bf
update ignore
beyondkmp Oct 9, 2024
38ba984
update yarn.lock
beyondkmp Oct 9, 2024
d6377ff
update yarn.lock
beyondkmp Oct 9, 2024
4d42331
update yarn.lock
beyondkmp Oct 9, 2024
6c2469d
fix ut
beyondkmp Oct 9, 2024
34e8f2e
format code
beyondkmp Oct 10, 2024
cb9a8e3
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 10, 2024
d691e60
delete filter
beyondkmp Oct 10, 2024
37e467f
format code
beyondkmp Oct 10, 2024
b9c85e0
add ut
beyondkmp Oct 10, 2024
f3cb216
fix ut
beyondkmp Oct 10, 2024
7bdeb9d
format code
beyondkmp Oct 10, 2024
7b58b83
fix ut
beyondkmp Oct 10, 2024
b0db426
udpate snap
beyondkmp Oct 10, 2024
43e0c96
add ut
beyondkmp Oct 10, 2024
5368fa3
update snapshot
beyondkmp Oct 10, 2024
4d6f786
add ut
beyondkmp Oct 10, 2024
fb5e01e
add comments
beyondkmp Oct 10, 2024
1039ed0
update node version
beyondkmp Oct 10, 2024
9d06f58
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 10, 2024
4804709
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 10, 2024
8f582c1
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 11, 2024
457c2e5
fix ut
beyondkmp Oct 11, 2024
d2e2de7
add ut for hoist
beyondkmp Oct 12, 2024
e6f3b59
add comments
beyondkmp Oct 12, 2024
7c37814
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 12, 2024
b57ffc8
fix ut
beyondkmp Oct 12, 2024
72dc559
format code
beyondkmp Oct 12, 2024
7d37e19
format code
beyondkmp Oct 12, 2024
d50c66d
update readme
beyondkmp Oct 12, 2024
b4d620d
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 14, 2024
6a1ef9b
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 15, 2024
c42b429
fix lint
beyondkmp Oct 15, 2024
e01bc6f
fix npm list error
beyondkmp Oct 15, 2024
875af7c
format code
beyondkmp Oct 15, 2024
61fb295
format code
beyondkmp Oct 15, 2024
f85abe1
format code
beyondkmp Oct 15, 2024
fe15c95
fix ut
beyondkmp Oct 15, 2024
3899607
fix ut
beyondkmp Oct 15, 2024
be11d50
format code
beyondkmp Oct 15, 2024
0dd953f
fix ut
beyondkmp Oct 15, 2024
6d919e9
fix ut
beyondkmp Oct 15, 2024
641eb43
fix yarn error
beyondkmp Oct 16, 2024
f844771
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 16, 2024
1ea244d
fix comments
beyondkmp Oct 24, 2024
2dee313
fix https://github.com/npm/npm/issues/17624
beyondkmp Oct 24, 2024
0595127
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 24, 2024
1f58fd4
delete log.filepath
beyondkmp Oct 29, 2024
d02d442
Merge branch 'master' into nodeModulesCollectorNew
beyondkmp Oct 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use detect
  • Loading branch information
beyondkmp committed Oct 5, 2024
commit 24dbf440020e5e4920062ae18e15a792ba48e7b2
2 changes: 1 addition & 1 deletion packages/app-builder-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"semver": "^7.3.8",
"tar": "^6.1.12",
"temp-file": "^3.4.0",
"node-module-collector": "1.1.2"
"node-module-collector": "1.1.3"
},
"///": "babel in devDependencies for proton tests",
"devDependencies": {
Expand Down
48 changes: 28 additions & 20 deletions packages/app-builder-lib/src/util/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getProjectRootPath } from "@electron/rebuild/lib/search-module"
import { rebuild as remoteRebuild } from "./rebuild/rebuild"
import { executeAppBuilderAndWriteJson } from "./appBuilder"
import { RebuildMode } from "@electron/rebuild/lib/types"
import { PM, detect, getNpmVersion } from "node-module-collector"

export async function installOrRebuild(config: Configuration, appDir: string, options: RebuildOptions, forceInstall = false) {
const effectiveOptions: RebuildOptions = {
Expand Down Expand Up @@ -78,13 +79,16 @@ export function getGypEnv(frameworkInfo: DesktopFrameworkInfo, platform: NodeJS.
}
}

function checkYarnBerry() {
const npmUserAgent = process.env["npm_config_user_agent"] || ""
const regex = /yarn\/(\d+)\./gm
async function checkYarnBerry(pm:PM) {
if (pm !== "yarn") {
return false
}
const version = await getNpmVersion(pm)
beyondkmp marked this conversation as resolved.
Show resolved Hide resolved
if (version == null || version.split('.').length < 1) {
return false
}

const yarnVersionMatch = regex.exec(npmUserAgent)
const yarnMajorVersion = Number(yarnVersionMatch?.[1] ?? 0)
return yarnMajorVersion >= 2
return version.split('.')[0] >= "2"
}

async function installDependencies(config: Configuration, appDir: string, options: RebuildOptions): Promise<any> {
Expand All @@ -93,26 +97,21 @@ async function installDependencies(config: Configuration, appDir: string, option
const additionalArgs = options.additionalArgs

log.info({ platform, arch, appDir }, `installing production dependencies`)
let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
const pm = await detect({ cwd: appDir })
const execArgs = ["install"]
const isYarnBerry = checkYarnBerry()
const isYarnBerry = checkYarnBerry(pm)
if (!isYarnBerry) {
if (process.env.NPM_NO_BIN_LINKS === "true") {
execArgs.push("--no-bin-links")
}
execArgs.push("--production")
}

if (!isRunningYarn(execPath)) {
if (!isRunningYarn(pm)) {
execArgs.push("--prefer-offline")
}

if (execPath == null) {
execPath = getPackageToolPath()
} else if (!isYarnBerry) {
execArgs.unshift(execPath)
execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
}
const execPath = getPackageToolPath(pm)

if (additionalArgs != null) {
execArgs.push(...additionalArgs)
Expand Down Expand Up @@ -146,17 +145,26 @@ export async function nodeGypRebuild(platform: NodeJS.Platform, arch: string, fr
await spawn(nodeGyp, args, { env: getGypEnv(frameworkInfo, platform, arch, true) })
}

function getPackageToolPath() {
function getPackageToolPath(pm: PM) {
if (process.env.FORCE_YARN === "true") {
return process.platform === "win32" ? "yarn.cmd" : "yarn"
} else {
return process.platform === "win32" ? "npm.cmd" : "npm"
}

switch(pm) {
case "yarn":
return process.platform === "win32" ? "yarn.cmd" : "yarn"
case "pnpm":
return process.platform === "win32" ? "pnpm.cmd" : "pnpm"
case "npm":
return process.platform === "win32" ? "npm.cmd" : "npm"
default:
return process.platform === "win32" ? "npm.cmd" : "npm"
}
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
}

function isRunningYarn(execPath: string | null | undefined) {
function isRunningYarn(pm: PM) {
const userAgent = process.env.npm_config_user_agent
return process.env.FORCE_YARN === "true" || (execPath != null && path.basename(execPath).startsWith("yarn")) || (userAgent != null && /\byarn\b/.test(userAgent))
return process.env.FORCE_YARN === "true" || pm === "yarn" || (userAgent != null && /\byarn\b/.test(userAgent))
}

export interface RebuildOptions {
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.