Skip to content
Draft
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
1,091 changes: 755 additions & 336 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ComponentMap } from '@teambit/component';
import { type DependenciesGraph } from '@teambit/objects';
import type { Logger } from '@teambit/logger';
import type { PathAbsolute } from '@teambit/toolbox.path.path';
import type { PeerDependencyRules, ProjectManifest } from '@pnpm/types';
import type { PeerDependencyRules, ProjectManifest, IgnoredBuilds } from '@pnpm/types';
import { MainAspectNotInstallable, RootDirNotDefined } from './exceptions';
import type { PackageManager, PackageManagerInstallOptions, PackageImportMethod } from './package-manager';
import type { WorkspacePolicy } from './policy';
Expand Down Expand Up @@ -152,7 +152,7 @@ export class DependencyInstaller {
componentDirectoryMap: ComponentMap<string>,
options: InstallOptions = DEFAULT_INSTALL_OPTIONS,
packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS
): Promise<{ dependenciesChanged: boolean }> {
): Promise<{ dependenciesChanged: boolean; ignoredBuilds?: IgnoredBuilds }> {
const args = {
componentDirectoryMap,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export interface DependencyResolverWorkspaceConfig {
* Fine-grained control over dependency lifecycle scripts. Allows explicitly permitting (true), blocking (false), or warning ('warn')
* for specific dependencies' "preinstall", "install", and "postinstall" scripts during installation.
*/
allowScripts?: Record<string, boolean | 'warn'>;
allowScripts?: Record<string, boolean | string>;

/**
* Set this to true in order to allow all dependencies to run install scripts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ export class DependencyResolverMain {
};
}

updateAllowedScripts(newAllowedScripts: Record<string, boolean>): void {
updateAllowedScripts(newAllowedScripts: Record<string, boolean | string>): void {
this.config.allowScripts = {
...this.config.allowScripts,
...newAllowedScripts,
Expand Down
4 changes: 2 additions & 2 deletions scopes/dependencies/dependency-resolver/package-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PeerDependencyIssuesByProjects } from '@pnpm/core';
import type { PeerDependencyRules, ProjectManifest, DependencyManifest } from '@pnpm/types';
import type { PeerDependencyRules, ProjectManifest, DependencyManifest, IgnoredBuilds } from '@pnpm/types';
import type { ComponentID, ComponentMap, Component } from '@teambit/component';
import { type DependenciesGraph } from '@teambit/objects';
import type { Registries } from '@teambit/pkg.entities.registry';
Expand Down Expand Up @@ -193,7 +193,7 @@ export interface PackageManager {
install(
context: InstallationContext,
options: PackageManagerInstallOptions
): Promise<{ dependenciesChanged: boolean }>;
): Promise<{ dependenciesChanged: boolean; ignoredBuilds?: IgnoredBuilds }>;

pruneModules?(rootDir: string): Promise<void>;

Expand Down
14 changes: 13 additions & 1 deletion scopes/dependencies/pnpm/lynx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ export interface ReportOptions {
process?: NodeJS.Process;
}

export interface InstallResult {
dependenciesChanged: boolean;
rebuild: RebuildFn;
storeDir: string;
depsRequiringBuild?: DepPath[];
ignoredBuilds?: Set<DepPath>;
}

export async function install(
rootDir: string,
manifestsByPaths: Record<string, ProjectManifest>,
Expand Down Expand Up @@ -225,7 +233,7 @@ export async function install(
Pick<CreateStoreControllerOptions, 'packageImportMethod' | 'pnpmHomeDir' | 'preferOffline'>,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
logger?: Logger
): Promise<{ dependenciesChanged: boolean; rebuild: RebuildFn; storeDir: string; depsRequiringBuild?: DepPath[] }> {
): Promise<InstallResult> {
const externalDependencies = new Set<string>();
const readPackage = createReadPackageHooks(options);
if (options?.rootComponents && !options?.rootComponentsForCapsules) {
Expand Down Expand Up @@ -325,6 +333,7 @@ export async function install(

let dependenciesChanged = false;
let depsRequiringBuild: DepPath[] | undefined;
let ignoredBuilds: Set<DepPath> | undefined;
if (!options.dryRun) {
let stopReporting: Function | undefined;
if (!options.hidePackageManagerOutput) {
Expand All @@ -339,6 +348,8 @@ export async function install(
installsRunning[rootDir] = mutateModules(packagesToBuild, opts);
const installResult = await installsRunning[rootDir];
depsRequiringBuild = installResult.depsRequiringBuild?.sort();
ignoredBuilds = installResult.ignoredBuilds;
console.log(ignoredBuilds)
if (depsRequiringBuild != null) {
await addDepsRequiringBuildToLockfile(rootDir, depsRequiringBuild);
}
Expand Down Expand Up @@ -378,6 +389,7 @@ export async function install(
},
storeDir: storeController.dir,
depsRequiringBuild,
ignoredBuilds,
};
}

Expand Down
5 changes: 3 additions & 2 deletions scopes/dependencies/pnpm/pnpm.package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface InstallResult {
rebuild: RebuildFn;
storeDir: string;
depsRequiringBuild?: DepPath[];
ignoredBuilds?: Set<DepPath>;
}

type ReadConfigResult = Promise<{ config: Config; warnings: string[] }>;
Expand Down Expand Up @@ -164,7 +165,7 @@ export class PnpmPackageManager implements PackageManager {
});
}
this.modulesManifestCache.delete(rootDir);
const { dependenciesChanged, rebuild, storeDir, depsRequiringBuild } = await install(
const { dependenciesChanged, rebuild, storeDir, depsRequiringBuild, ignoredBuilds } = await install(
rootDir,
manifests,
config.storeDir,
Expand Down Expand Up @@ -224,7 +225,7 @@ export class PnpmPackageManager implements PackageManager {
// this.logger.console('-------------------------END PNPM OUTPUT-------------------------');
// this.logger.consoleSuccess('installing dependencies using pnpm');
}
return { dependenciesChanged, rebuild, storeDir, depsRequiringBuild };
return { dependenciesChanged, rebuild, storeDir, depsRequiringBuild, ignoredBuilds };
}

async getPeerDependencyIssues(
Expand Down
10 changes: 9 additions & 1 deletion scopes/workspace/install/install.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export class InstallMain {
// are not added to the manifests.
// This is an issue when installation is done using root components.
hasMissingLocalComponents = hasRootComponents && hasComponentsFromWorkspaceInMissingDeps(current);
const { dependenciesChanged } = await installer.installComponents(
const { dependenciesChanged, ignoredBuilds } = await installer.installComponents(
this.workspace.path,
current.manifests,
mergedRootPolicy,
Expand All @@ -431,6 +431,14 @@ export class InstallMain {
},
pmInstallOptions
);
if (ignoredBuilds?.size) {
const allowScripts = {};
for (const ignoredBuild of ignoredBuilds.values()) {
allowScripts[ignoredBuild] ??= 'change to true or false';
}
this.dependencyResolver.updateAllowedScripts(allowScripts);
await this.dependencyResolver.persistConfig('update allowScripts configuration');
}
this.workspace.inInstallAfterPmContext = true;
let cacheCleared = false;
await this.linkCodemods(compDirMap);
Expand Down