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: prefer offline install #7509

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export class DependencyInstaller {

private neverBuiltDependencies?: string[],

private preferOffline?: boolean,

private installingContext: DepInstallerContext = {}
) {}

Expand Down Expand Up @@ -194,6 +196,7 @@ export class DependencyInstaller {
peerDependencyRules: this.peerDependencyRules,
hidePackageManagerOutput,
neverBuiltDependencies: ['core-js', ...(this.neverBuiltDependencies ?? [])],
preferOffline: this.preferOffline,
...packageManagerOptions,
};
if (options.installTeambitBit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ export interface DependencyResolverWorkspaceConfig {
* of the listed packages will not be executed during installation.
*/
neverBuiltDependencies?: string[];

/**
* If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server.
*/
preferOffline?: boolean;
}

export interface DependencyResolverVariantConfig {
Expand Down Expand Up @@ -700,6 +705,7 @@ export class DependencyResolverMain {
this.config.engineStrict,
this.config.peerDependencyRules,
this.config.neverBuiltDependencies,
this.config.preferOffline,
options.installingContext
);
}
Expand Down
2 changes: 2 additions & 0 deletions scopes/dependencies/dependency-resolver/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export type PackageManagerInstallOptions = {
hidePackageManagerOutput?: boolean;

neverBuiltDependencies?: string[];

preferOffline?: boolean;
};

export type PackageManagerGetPeerDependencyIssuesOptions = PackageManagerInstallOptions;
Expand Down
6 changes: 4 additions & 2 deletions scopes/dependencies/pnpm/lynx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function createStoreController(
registries: Registries;
proxyConfig: PackageManagerProxyConfig;
networkConfig: PackageManagerNetworkConfig;
} & Pick<CreateStoreControllerOptions, 'packageImportMethod' | 'pnpmHomeDir'>
} & Pick<CreateStoreControllerOptions, 'packageImportMethod' | 'pnpmHomeDir' | 'preferOffline'>
): Promise<{ ctrl: StoreController; dir: string }> {
const authConfig = getAuthConfig(options.registries);
const opts: CreateStoreControllerOptions = {
Expand All @@ -71,6 +71,7 @@ async function createStoreController(
maxSockets: options.networkConfig.maxSockets,
networkConcurrency: options.networkConfig.networkConcurrency,
packageImportMethod: options.packageImportMethod,
preferOffline: options.preferOffline,
resolveSymlinksInInjectedDirs: true,
pnpmHomeDir: options.pnpmHomeDir,
};
Expand Down Expand Up @@ -181,7 +182,7 @@ export async function install(
| 'peerDependencyRules'
| 'neverBuiltDependencies'
> &
Pick<CreateStoreControllerOptions, 'packageImportMethod' | 'pnpmHomeDir'>,
Pick<CreateStoreControllerOptions, 'packageImportMethod' | 'pnpmHomeDir' | 'preferOffline'>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
logger?: Logger
): Promise<{ dependenciesChanged: boolean }> {
Expand Down Expand Up @@ -217,6 +218,7 @@ export async function install(
storeDir,
cacheDir,
registries,
preferOffline: options?.preferOffline,
proxyConfig,
networkConfig,
packageImportMethod: options?.packageImportMethod,
Expand Down
1 change: 1 addition & 0 deletions scopes/dependencies/pnpm/pnpm.package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class PnpmPackageManager implements PackageManager {
? ['*']
: ['@eslint/plugin-*', '*eslint-plugin*', '@prettier/plugin-*', '*prettier-plugin-*'],
packageImportMethod: installOptions.packageImportMethod ?? config.packageImportMethod,
preferOffline: installOptions.preferOffline,
rootComponents: installOptions.rootComponents,
rootComponentsForCapsules: installOptions.rootComponentsForCapsules,
peerDependencyRules: installOptions.peerDependencyRules,
Expand Down