mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
👷 build: disable pnpm gvs for desktop ci (#14357)
* 👷 build: disable pnpm gvs for desktop ci * 👷 build: increase desktop install heap * 👷 build: raise linux desktop file limit * 👷 build: skip desktop package rebuild * 👷 build: hoist desktop isolated install * 👷 build: skip desktop dependency collector * 👷 build: mark desktop modules externally handled * 👷 build: limit desktop native runtime deps * 👷 build: include get-windows runtime resolver deps
This commit is contained in:
@@ -16,8 +16,12 @@ runs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: pnpm install --node-linker=hoisted
|
run: pnpm install --node-linker=hoisted --config.enable-global-virtual-store=false
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: --max-old-space-size=8192
|
||||||
|
|
||||||
- name: Install deps on Desktop
|
- name: Install deps on Desktop
|
||||||
shell: bash
|
shell: bash
|
||||||
run: npm run install-isolated --prefix=./apps/desktop
|
run: pnpm --dir ./apps/desktop install --node-linker=hoisted --config.enable-global-virtual-store=false
|
||||||
|
env:
|
||||||
|
NODE_OPTIONS: --max-old-space-size=8192
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
uses: ./.github/actions/setup-env
|
uses: ./.github/actions/setup-env
|
||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: pnpm install
|
run: pnpm install --config.enable-global-virtual-store=false
|
||||||
env:
|
env:
|
||||||
NODE_OPTIONS: --max-old-space-size=8192
|
NODE_OPTIONS: --max-old-space-size=8192
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: pnpm install
|
run: pnpm install --config.enable-global-virtual-store=false
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: bun run lint
|
run: bun run lint
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ jobs:
|
|||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: pnpm install
|
run: pnpm install --config.enable-global-virtual-store=false
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: bun run lint
|
run: bun run lint
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ const config = {
|
|||||||
);
|
);
|
||||||
console.info('✅ CLI bundle copied to resources/bin/lobe-cli.js');
|
console.info('✅ CLI bundle copied to resources/bin/lobe-cli.js');
|
||||||
},
|
},
|
||||||
|
// Native dependencies are rebuilt during the isolated desktop install and
|
||||||
|
// copied explicitly by the hooks here. Returning false marks node_modules as
|
||||||
|
// externally handled, so electron-builder does not invoke its pnpm collector
|
||||||
|
// during packaging.
|
||||||
|
beforeBuild: () => false,
|
||||||
/**
|
/**
|
||||||
* AfterPack hook for post-processing:
|
* AfterPack hook for post-processing:
|
||||||
* 1. Copy native modules to asar.unpacked (resolving pnpm symlinks)
|
* 1. Copy native modules to asar.unpacked (resolving pnpm symlinks)
|
||||||
@@ -290,7 +295,6 @@ const config = {
|
|||||||
{ arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'zip' },
|
{ arch: [arch === 'arm64' ? 'arm64' : 'x64'], target: 'zip' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
npmRebuild: true,
|
|
||||||
nsis: {
|
nsis: {
|
||||||
allowToChangeInstallationDirectory: true,
|
allowToChangeInstallationDirectory: true,
|
||||||
artifactName: '${productName}-${version}-setup.${ext}',
|
artifactName: '${productName}-${version}-setup.${ext}',
|
||||||
|
|||||||
@@ -40,6 +40,39 @@ export const nativeModules = [
|
|||||||
'node-screenshots',
|
'node-screenshots',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const optionalNativePackagePrefixes = new Map([
|
||||||
|
['@napi-rs/canvas', ['@napi-rs/canvas-']],
|
||||||
|
['node-screenshots', ['node-screenshots-']],
|
||||||
|
]);
|
||||||
|
|
||||||
|
const runtimeOptionalDependencies = new Map([['get-windows', ['@mapbox/node-pre-gyp']]]);
|
||||||
|
|
||||||
|
const runtimeDependencyOverrides = new Map([
|
||||||
|
// get-windows imports @mapbox/node-pre-gyp at runtime only for find().
|
||||||
|
// Keep the narrow find() dependency path and avoid shipping its install,
|
||||||
|
// publish, and CLI dependency tree into app.asar.
|
||||||
|
['@mapbox/node-pre-gyp', ['detect-libc', 'nopt', 'npmlog', 'semver']],
|
||||||
|
]);
|
||||||
|
|
||||||
|
function getRuntimeDependencies(moduleName, dependencies) {
|
||||||
|
return runtimeDependencyOverrides.get(moduleName) || Object.keys(dependencies);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRuntimeOptionalDependencies(moduleName, optionalDependencies) {
|
||||||
|
const prefixes = optionalNativePackagePrefixes.get(moduleName);
|
||||||
|
const dependencies = [...(runtimeOptionalDependencies.get(moduleName) || [])];
|
||||||
|
|
||||||
|
if (prefixes) {
|
||||||
|
dependencies.push(
|
||||||
|
...Object.keys(optionalDependencies).filter((dep) =>
|
||||||
|
prefixes.some((prefix) => dep.startsWith(prefix)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively resolve all dependencies of a module
|
* Recursively resolve all dependencies of a module
|
||||||
* @param {string} moduleName - The module to resolve
|
* @param {string} moduleName - The module to resolve
|
||||||
@@ -73,13 +106,15 @@ function resolveDependencies(
|
|||||||
const optionalDependencies = packageJson.optionalDependencies || {};
|
const optionalDependencies = packageJson.optionalDependencies || {};
|
||||||
|
|
||||||
// Resolve regular dependencies
|
// Resolve regular dependencies
|
||||||
for (const dep of Object.keys(dependencies)) {
|
for (const dep of getRuntimeDependencies(moduleName, dependencies)) {
|
||||||
resolveDependencies(dep, visited, nodeModulesPath);
|
resolveDependencies(dep, visited, nodeModulesPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also resolve optional dependencies (important for native modules like @napi-rs/canvas
|
// Only include optional packages that are runtime native binaries for the
|
||||||
// which have platform-specific binaries in optional deps)
|
// module itself. Native packages can also list install-time toolchains such
|
||||||
for (const dep of Object.keys(optionalDependencies)) {
|
// as node-gyp or node-pre-gyp as optional deps; those must not be copied or
|
||||||
|
// externalized into the packaged Electron app.
|
||||||
|
for (const dep of getRuntimeOptionalDependencies(moduleName, optionalDependencies)) {
|
||||||
resolveDependencies(dep, visited, nodeModulesPath);
|
resolveDependencies(dep, visited, nodeModulesPath);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user