Skip to content

Commit 63499e3

Browse files
committed
feat: Consume named exports of sibling modules
1 parent c489810 commit 63499e3

File tree

156 files changed

+413
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+413
-413
lines changed

commands/__mocks__/@lerna/output.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
const chalk = require("chalk");
4-
const multiLineTrimRight = require("@lerna-test/multi-line-trim-right");
4+
const { multiLineTrimRight } = require("@lerna-test/multi-line-trim-right");
55

66
// keep snapshots stable cross-platform
77
chalk.level = 0;

commands/add/command.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const filterOptions = require("@lerna/filter-options");
3+
const { filterOptions } = require("@lerna/filter-options");
44

55
/**
66
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module

commands/add/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ const path = require("path");
77
const pacote = require("pacote");
88
const semver = require("semver");
99

10-
const Command = require("@lerna/command");
10+
const { Command } = require("@lerna/command");
1111
const npmConf = require("@lerna/npm-conf");
1212
const bootstrap = require("@lerna/bootstrap");
13-
const ValidationError = require("@lerna/validation-error");
13+
const { ValidationError } = require("@lerna/validation-error");
1414
const { getFilteredPackages } = require("@lerna/filter-options");
1515
const getRangeToReference = require("./lib/get-range-to-reference");
1616

commands/bootstrap/__tests__/bootstrap-command.test.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ const fs = require("fs-extra");
99
const path = require("path");
1010

1111
// mocked or stubbed modules
12-
const rimrafDir = require("@lerna/rimraf-dir");
13-
const npmInstall = require("@lerna/npm-install");
14-
const runLifecycle = require("@lerna/run-lifecycle");
15-
const createSymlink = require("@lerna/create-symlink");
16-
const hasNpmVersion = require("@lerna/has-npm-version");
12+
const { rimrafDir } = require("@lerna/rimraf-dir");
13+
const { npmInstall, npmInstallDependencies } = require("@lerna/npm-install");
14+
const { runLifecycle } = require("@lerna/run-lifecycle");
15+
const { createSymlink } = require("@lerna/create-symlink");
16+
const { hasNpmVersion } = require("@lerna/has-npm-version");
1717

1818
// helpers
1919
const initFixture = require("@lerna-test/init-fixture")(__dirname);
20-
const normalizeRelativeDir = require("@lerna-test/normalize-relative-dir");
21-
const updateLernaConfig = require("@lerna-test/update-lerna-config");
20+
const { normalizeRelativeDir } = require("@lerna-test/normalize-relative-dir");
21+
const { updateLernaConfig } = require("@lerna-test/update-lerna-config");
2222

2323
// file under test
2424
const lernaBootstrap = require("@lerna-test/command-runner")(require("../command"));
2525

2626
// assertion helpers
2727
const installedPackagesInDirectories = (testDir) =>
28-
npmInstall.dependencies.mock.calls.reduce((obj, [pkg, dependencies]) => {
28+
npmInstallDependencies.mock.calls.reduce((obj, [pkg, dependencies]) => {
2929
const relative = normalizeRelativeDir(testDir, pkg.location);
3030
obj[relative || "ROOT"] = dependencies;
3131
return obj;
@@ -64,7 +64,7 @@ describe("BootstrapCommand", () => {
6464
// we stub npmInstall in most tests because
6565
// we already have enough tests of npmInstall
6666
npmInstall.mockResolvedValue();
67-
npmInstall.dependencies.mockResolvedValue();
67+
npmInstallDependencies.mockResolvedValue();
6868

6969
// stub runLifecycle because it is a huge source
7070
// of slowness when running tests for no good reason
@@ -111,7 +111,7 @@ describe("BootstrapCommand", () => {
111111
await lernaBootstrap(testDir)("--ignore-scripts");
112112

113113
expect(runLifecycle).not.toHaveBeenCalled();
114-
expect(npmInstall.dependencies).toHaveBeenCalledWith(
114+
expect(npmInstallDependencies).toHaveBeenCalledWith(
115115
expect.objectContaining({
116116
name: "package-prepare",
117117
}),
@@ -144,7 +144,7 @@ describe("BootstrapCommand", () => {
144144
expect(removedDirectories(testDir)).toMatchSnapshot();
145145

146146
// root includes explicit dependencies and hoisted from leaves
147-
expect(npmInstall.dependencies).toHaveBeenCalledWith(
147+
expect(npmInstallDependencies).toHaveBeenCalledWith(
148148
expect.objectContaining({
149149
name: "basic",
150150
}),
@@ -159,7 +159,7 @@ describe("BootstrapCommand", () => {
159159
);
160160

161161
// [email protected] differs from the more common foo@^1.0.0
162-
expect(npmInstall.dependencies).toHaveBeenLastCalledWith(
162+
expect(npmInstallDependencies).toHaveBeenLastCalledWith(
163163
expect.objectContaining({
164164
name: "package-3",
165165
}),
@@ -219,7 +219,7 @@ describe("BootstrapCommand", () => {
219219
await lernaBootstrap(testDir)("--ci");
220220

221221
expect(hasNpmVersion).toHaveBeenLastCalledWith(">=5.7.0");
222-
expect(npmInstall.dependencies.mock.calls[0][2]).toEqual({
222+
expect(npmInstallDependencies.mock.calls[0][2]).toEqual({
223223
subCommand: "ci",
224224
registry: undefined,
225225
npmClient: "npm",
@@ -236,7 +236,7 @@ describe("BootstrapCommand", () => {
236236

237237
await lernaBootstrap(testDir)("--ci");
238238

239-
expect(npmInstall.dependencies.mock.calls[0][2]).toEqual({
239+
expect(npmInstallDependencies.mock.calls[0][2]).toEqual({
240240
registry: undefined,
241241
npmClient: "npm",
242242
npmClientArgs: [],
@@ -250,7 +250,7 @@ describe("BootstrapCommand", () => {
250250

251251
await lernaBootstrap(testDir)("--hoist", "package-*", "--ci");
252252

253-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
253+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
254254
subCommand: "install", // not "ci"
255255
npmClient: "npm",
256256
npmClientArgs: ["--no-save"],
@@ -270,7 +270,7 @@ describe("BootstrapCommand", () => {
270270
await lernaBootstrap(testDir)();
271271

272272
expect(hasNpmVersion).not.toHaveBeenCalled();
273-
expect(npmInstall.dependencies.mock.calls[0][2]).toEqual({
273+
expect(npmInstallDependencies.mock.calls[0][2]).toEqual({
274274
registry: undefined,
275275
npmClient: "npm",
276276
npmClientArgs: [],
@@ -350,7 +350,7 @@ describe("BootstrapCommand", () => {
350350

351351
expect(installedPackagesInDirectories(testDir)).toMatchSnapshot();
352352
expect(symlinkedDirectories(testDir)).toMatchSnapshot();
353-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
353+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
354354
subCommand: "install", // not "ci"
355355
npmClient: "npm",
356356
npmClientArgs: ["--no-save"],
@@ -362,7 +362,7 @@ describe("BootstrapCommand", () => {
362362

363363
await lernaBootstrap(testDir)("--scope", "@test/package-2", "--npm-client", "yarn", "--ci");
364364

365-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
365+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
366366
npmClient: "yarn",
367367
npmClientArgs: ["--pure-lockfile"],
368368
});
@@ -373,7 +373,7 @@ describe("BootstrapCommand", () => {
373373

374374
await lernaBootstrap(testDir)();
375375

376-
expect(npmInstall.dependencies).toHaveBeenCalledWith(
376+
expect(npmInstallDependencies).toHaveBeenCalledWith(
377377
expect.objectContaining({
378378
name: "@test/package-2",
379379
}),
@@ -450,7 +450,7 @@ describe("BootstrapCommand", () => {
450450

451451
await lernaBootstrap(testDir)("--npm-client", "yarn");
452452

453-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
453+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
454454
npmClient: "yarn",
455455
mutex: expect.stringMatching(/^network:\d+$/),
456456
});
@@ -461,7 +461,7 @@ describe("BootstrapCommand", () => {
461461

462462
await lernaBootstrap(testDir)("--npm-client", "yarn", "--mutex", "file:/test/this/path");
463463

464-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
464+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
465465
npmClient: "yarn",
466466
mutex: "file:/test/this/path",
467467
});
@@ -486,7 +486,7 @@ describe("BootstrapCommand", () => {
486486

487487
await lernaBootstrap(testDir)();
488488

489-
expect(npmInstall.dependencies).not.toHaveBeenCalled();
489+
expect(npmInstallDependencies).not.toHaveBeenCalled();
490490
});
491491

492492
it("hoists appropriately", async () => {
@@ -531,7 +531,7 @@ describe("BootstrapCommand", () => {
531531

532532
await lernaBootstrap(testDir)();
533533

534-
expect(npmInstall.dependencies).not.toHaveBeenCalled();
534+
expect(npmInstallDependencies).not.toHaveBeenCalled();
535535
});
536536
});
537537

@@ -542,7 +542,7 @@ describe("BootstrapCommand", () => {
542542
await lernaBootstrap(testDir)();
543543

544544
expect(installedPackagesInDirectories(testDir)).toMatchSnapshot();
545-
expect(npmInstall.dependencies).toHaveBeenLastCalledWith(
545+
expect(npmInstallDependencies).toHaveBeenLastCalledWith(
546546
expect.objectContaining({
547547
name: "@test/package-1",
548548
}),
@@ -563,7 +563,7 @@ describe("BootstrapCommand", () => {
563563

564564
await lernaBootstrap(testDir)("--", "--no-optional", "--production");
565565

566-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
566+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
567567
npmClientArgs: ["--no-optional", "--production"],
568568
});
569569
});
@@ -575,7 +575,7 @@ describe("BootstrapCommand", () => {
575575

576576
await lernaBootstrap(testDir)("--", "--no-optional");
577577

578-
expect(npmInstall.dependencies.mock.calls[0][2]).toMatchObject({
578+
expect(npmInstallDependencies.mock.calls[0][2]).toMatchObject({
579579
npmClientArgs: ["--production", "--no-optional"],
580580
});
581581
});
@@ -588,7 +588,7 @@ describe("BootstrapCommand", () => {
588588

589589
await lernaBootstrap(testDir)();
590590

591-
expect(npmInstall.dependencies).not.toHaveBeenCalled();
591+
expect(npmInstallDependencies).not.toHaveBeenCalled();
592592
expect(npmInstall).toHaveBeenLastCalledWith(
593593
expect.objectContaining({ name: "root" }),
594594
expect.objectContaining({
@@ -614,7 +614,7 @@ describe("BootstrapCommand", () => {
614614

615615
await lernaBootstrap(testDir)();
616616

617-
expect(npmInstall.dependencies).not.toHaveBeenCalled();
617+
expect(npmInstallDependencies).not.toHaveBeenCalled();
618618
expect(npmInstall).toHaveBeenLastCalledWith(
619619
expect.objectContaining({ name: "relative-file-specs" }),
620620
expect.objectContaining({

commands/bootstrap/command.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const filterOptions = require("@lerna/filter-options");
3+
const { filterOptions } = require("@lerna/filter-options");
44

55
/**
66
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module

commands/bootstrap/index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ const pMap = require("p-map");
88
const pMapSeries = require("p-map-series");
99
const pWaterfall = require("p-waterfall");
1010

11-
const Command = require("@lerna/command");
12-
const rimrafDir = require("@lerna/rimraf-dir");
13-
const hasNpmVersion = require("@lerna/has-npm-version");
14-
const npmInstall = require("@lerna/npm-install");
11+
const { Command } = require("@lerna/command");
12+
const { rimrafDir } = require("@lerna/rimraf-dir");
13+
const { hasNpmVersion } = require("@lerna/has-npm-version");
14+
const { npmInstall, npmInstallDependencies } = require("@lerna/npm-install");
1515
const { createRunner } = require("@lerna/run-lifecycle");
16-
const runTopologically = require("@lerna/run-topologically");
17-
const symlinkBinary = require("@lerna/symlink-binary");
18-
const symlinkDependencies = require("@lerna/symlink-dependencies");
19-
const ValidationError = require("@lerna/validation-error");
16+
const { runTopologically } = require("@lerna/run-topologically");
17+
const { symlinkBinary } = require("@lerna/symlink-binary");
18+
const { symlinkDependencies } = require("@lerna/symlink-dependencies");
19+
const { ValidationError } = require("@lerna/validation-error");
2020
const { getFilteredPackages } = require("@lerna/filter-options");
21-
const PackageGraph = require("@lerna/package-graph");
22-
const pulseTillDone = require("@lerna/pulse-till-done");
21+
const { PackageGraph } = require("@lerna/package-graph");
22+
const { pulseTillDone } = require("@lerna/pulse-till-done");
2323

2424
const hasDependencyInstalled = require("./lib/has-dependency-installed");
2525
const isHoistedPackage = require("./lib/is-hoisted-package");
@@ -478,7 +478,7 @@ class BootstrapCommand extends Command {
478478
tracker.info("hoist", "Installing hoisted dependencies into root");
479479
}
480480

481-
const promise = npmInstall.dependencies(rootPkg, depsToInstallInRoot, this.npmConfig);
481+
const promise = npmInstallDependencies(rootPkg, depsToInstallInRoot, this.npmConfig);
482482

483483
return pulseTillDone(promise)
484484
.then(() =>
@@ -557,7 +557,7 @@ class BootstrapCommand extends Command {
557557
if (deps.some(({ isSatisfied }) => !isSatisfied)) {
558558
actions.push(() => {
559559
const dependencies = deps.map(({ dependency }) => dependency);
560-
const promise = npmInstall.dependencies(leafNode.pkg, dependencies, leafNpmConfig);
560+
const promise = npmInstallDependencies(leafNode.pkg, dependencies, leafNpmConfig);
561561

562562
return pulseTillDone(promise).then(() => {
563563
tracker.verbose("installed leaf", leafNode.name);

commands/changed/__tests__/changed-command.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"use strict";
22

33
// mocked modules
4-
const collectUpdates = require("@lerna/collect-updates");
5-
const output = require("@lerna/output");
4+
const { collectUpdates } = require("@lerna/collect-updates");
5+
const { output } = require("@lerna/output");
66

77
// helpers
88
const initFixture = require("@lerna-test/init-fixture")(__dirname);
9-
const loggingOutput = require("@lerna-test/logging-output");
10-
const updateLernaConfig = require("@lerna-test/update-lerna-config");
9+
const { loggingOutput } = require("@lerna-test/logging-output");
10+
const { updateLernaConfig } = require("@lerna-test/update-lerna-config");
1111

1212
// file under test
1313
const lernaChanged = require("@lerna-test/command-runner")(require("../command"));

commands/changed/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use strict";
22

3-
const Command = require("@lerna/command");
4-
const collectUpdates = require("@lerna/collect-updates");
3+
const { Command } = require("@lerna/command");
4+
const { collectUpdates } = require("@lerna/collect-updates");
55
const listable = require("@lerna/listable");
6-
const output = require("@lerna/output");
6+
const { output } = require("@lerna/output");
77

88
module.exports = factory;
99

commands/clean/__tests__/clean-command.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ const fs = require("fs-extra");
77
const path = require("path");
88

99
// mocked or stubbed modules
10-
const rimrafDir = require("@lerna/rimraf-dir");
10+
const { rimrafDir } = require("@lerna/rimraf-dir");
1111
const PromptUtilities = require("@lerna/prompt");
1212

1313
// helpers
1414
const initFixture = require("@lerna-test/init-fixture")(__dirname);
15-
const normalizeRelativeDir = require("@lerna-test/normalize-relative-dir");
15+
const { normalizeRelativeDir } = require("@lerna-test/normalize-relative-dir");
1616

1717
// file under test
1818
const lernaClean = require("@lerna-test/command-runner")(require("../command"));

commands/clean/command.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const filterOptions = require("@lerna/filter-options");
3+
const { filterOptions } = require("@lerna/filter-options");
44

55
/**
66
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module

commands/clean/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
const path = require("path");
44
const pMap = require("p-map");
55

6-
const Command = require("@lerna/command");
7-
const rimrafDir = require("@lerna/rimraf-dir");
6+
const { Command } = require("@lerna/command");
7+
const { rimrafDir } = require("@lerna/rimraf-dir");
88
const PromptUtilities = require("@lerna/prompt");
99
const { getFilteredPackages } = require("@lerna/filter-options");
10-
const pulseTillDone = require("@lerna/pulse-till-done");
10+
const { pulseTillDone } = require("@lerna/pulse-till-done");
1111

1212
module.exports = factory;
1313

commands/create/__tests__/create-command.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const pacote = require("pacote");
1212

1313
// helpers
1414
const initFixture = require("@lerna-test/init-fixture")(__dirname);
15-
const gitAdd = require("@lerna-test/git-add");
15+
const { gitAdd } = require("@lerna-test/git-add");
1616

1717
// file under test
1818
const lernaCreate = require("@lerna-test/command-runner")(require("../command"));

commands/create/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ const npa = require("npm-package-arg");
1212
const pReduce = require("p-reduce");
1313
const slash = require("slash");
1414

15-
const Command = require("@lerna/command");
15+
const { Command } = require("@lerna/command");
1616
const ChildProcessUtilities = require("@lerna/child-process");
1717
const npmConf = require("@lerna/npm-conf");
18-
const ValidationError = require("@lerna/validation-error");
18+
const { ValidationError } = require("@lerna/validation-error");
1919
const builtinNpmrc = require("./lib/builtin-npmrc");
2020
const catFile = require("./lib/cat-file");
2121

0 commit comments

Comments
 (0)