Skip to content
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
10 changes: 3 additions & 7 deletions e2e/harmony/dependency-resolver.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@ import chai, { expect } from 'chai';
import path from 'path';
import fs from 'fs-extra';
import yaml from 'js-yaml';
import type { Modules } from '@pnpm/installing.modules-yaml';
import { generateRandomStr } from '@teambit/toolbox.string.random';
import rimraf from 'rimraf';
import { Extensions } from '@teambit/legacy.constants';
import { Helper, fixtures, NpmCiRegistry, supportNpmCiRegistryTesting } from '@teambit/legacy.e2e-helper';
import chaiFs from 'chai-fs';
import assertArrays from 'chai-arrays';
import type { ModulesManifest } from '../modules-manifest';
import { readModulesManifest } from '../modules-manifest';
chai.use(chaiFs);

chai.use(assertArrays);

async function readModulesManifest(modulesDir: string): Promise<Modules | null> {
const m = await import('@pnpm/installing.modules-yaml');
return m.readModulesManifest(modulesDir);
}

describe('dependency-resolver extension', function () {
let helper: Helper;
this.timeout(0);
Expand Down Expand Up @@ -291,7 +287,7 @@ describe('dependency-resolver extension', function () {
});
});
describe('hoist patterns', function () {
let modulesState: Modules | null;
let modulesState: ModulesManifest | null;
before(async () => {
helper = new Helper();
helper.scopeHelper.reInitWorkspace();
Expand Down
10 changes: 3 additions & 7 deletions e2e/harmony/pkg-manager-config.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ import path from 'path';
import chai, { expect } from 'chai';
import chaiString from 'chai-string';
import chaiFs from 'chai-fs';
import type { Modules } from '@pnpm/installing.modules-yaml';
import { Helper, NpmCiRegistry, supportNpmCiRegistryTesting } from '@teambit/legacy.e2e-helper';
import type { ModulesManifest } from '../modules-manifest';
import { readModulesManifest } from '../modules-manifest';

chai.use(chaiFs);
chai.use(chaiString);

async function readModulesManifest(modulesDir: string): Promise<Modules | null> {
const m = await import('@pnpm/installing.modules-yaml');
return m.readModulesManifest(modulesDir);
}

(supportNpmCiRegistryTesting ? describe : describe.skip)(
'workspace package-manager config is read when installation is in a capsule',
function () {
Expand Down Expand Up @@ -73,7 +69,7 @@ async function readModulesManifest(modulesDir: string): Promise<Modules | null>
});
});
describe('using pnpm', () => {
let modulesState: Modules | null;
let modulesState: ModulesManifest | null;
before(async () => {
helper.scopeHelper.reInitWorkspace();
helper.fs.outputFile('pnpm-workspace.yaml', 'hoistPattern:\n - capsule-hoist-pattern\n');
Expand Down
10 changes: 3 additions & 7 deletions e2e/harmony/pnpm-default-hoisting.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { expect } from 'chai';
import path from 'path';
import type { Modules } from '@pnpm/installing.modules-yaml';
import { Helper } from '@teambit/legacy.e2e-helper';

async function readModulesManifest(modulesDir: string): Promise<Modules | null> {
const m = await import('@pnpm/installing.modules-yaml');
return m.readModulesManifest(modulesDir);
}
import type { ModulesManifest } from '../modules-manifest';
import { readModulesManifest } from '../modules-manifest';

describe('pnpm install with default settings', function () {
let helper: Helper;
let modulesState: Modules | null;
let modulesState: ModulesManifest | null;
this.timeout(0);
before(async () => {
helper = new Helper();
Expand Down
23 changes: 23 additions & 0 deletions e2e/modules-manifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as nodeApi from '@pnpm/napi';

/**
* The subset of `.modules.yaml` the e2e suites assert on.
*
* `@pnpm/napi` returns the manifest untyped (`Record<string, unknown>`) because the engine owns
* the file's full shape; the fields below are the ones bit's own settings are expected to reach.
*/
export type ModulesManifest = {
hoistPattern?: string[];
publicHoistPattern?: string[];
};

/**
* read the `.modules.yaml` of an installed `node_modules`, or null when the directory has none.
*
* imported as a namespace rather than through `await import()`: the addon sets `module.exports`
* from a call, so cjs-module-lexer detects no named exports and node's esm loader would hand back
* a namespace holding only `default`.
*/
export async function readModulesManifest(modulesDir: string): Promise<ModulesManifest | null> {
return (await nodeApi.readModulesManifest(modulesDir)) as ModulesManifest | null;
}
Loading