Skip to content

Commit

Permalink
Merge branch 'next' into 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Feb 9, 2021
2 parents 72414ec + c3814b5 commit 7acf883
Show file tree
Hide file tree
Showing 398 changed files with 23,876 additions and 8,857 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.yaml
Expand Up @@ -61,11 +61,6 @@ overrides:
max-classes-per-file: "off"
node/no-extraneous-require: "off"
node/no-unpublished-require: "off"
node/no-unsupported-features/es-syntax:
- error
- ignores:
- asyncFunctions
# jest transpiles fast-async
no-console: "off"
- files:
- "test/fixtures/**"
Expand All @@ -74,6 +69,7 @@ overrides:
global-require: "off"
import/no-extraneous-dependencies: "off"
import/no-unresolved: "off"
import/no-useless-path-segments: "off"
node/no-extraneous-require: "off"
node/no-missing-require:
- error
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Expand Up @@ -22,6 +22,7 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm -g i npm@next-7
- run: npm ci
- run: npm run ci:lint

Expand All @@ -31,7 +32,7 @@ jobs:
strategy:
fail-fast: true
matrix:
node: [ 12, 10, 8 ]
node: [ 12, 10 ]
script: [ 'ci:test:unit', 'ci:test:integration' ]
steps:
- uses: actions/checkout@v2
Expand All @@ -48,6 +49,7 @@ jobs:
run: |
git config --global user.email test@example.com
git config --global user.name "Tester McPerson"
- run: npm -g i npm@next-7
- run: npm ci
- run: npm run ${{ matrix.script }}

Expand Down Expand Up @@ -80,6 +82,7 @@ jobs:
run: |
git config --global user.email test@example.com
git config --global user.name "Tester McPerson"
- run: npm -g i npm@next-7
- run: npm ci
- env:
LERNA_CI_TYPE: ${{ matrix.subset }}
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -9,7 +9,6 @@ language: node_js
node_js:
- "12"
- "10"
- "8"

os:
- linux
Expand Down
15 changes: 0 additions & 15 deletions babel.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion commands/__mocks__/@lerna/check-working-tree.js
Expand Up @@ -4,6 +4,6 @@ const mockCheckWorkingTree = jest.fn(() => Promise.resolve());
const mockThrowIfReleased = jest.fn(() => Promise.resolve());
const mockThrowIfUncommitted = jest.fn(() => Promise.resolve());

module.exports = mockCheckWorkingTree;
module.exports.checkWorkingTree = mockCheckWorkingTree;
module.exports.throwIfReleased = mockThrowIfReleased;
module.exports.throwIfUncommitted = mockThrowIfUncommitted;
6 changes: 3 additions & 3 deletions commands/__mocks__/@lerna/collect-updates.js
Expand Up @@ -8,7 +8,7 @@ const updated = new Map();

const mockCollectUpdates = jest.fn((filteredPackages, packageGraph, { cwd }) => {
const targets = updated.get(cwd);
const updates = targets ? new Map(targets.map(name => [name, packageGraph.get(name)])) : packageGraph;
const updates = targets ? new Map(targets.map((name) => [name, packageGraph.get(name)])) : packageGraph;

return Array.from(updates.values());
});
Expand All @@ -20,7 +20,7 @@ afterEach(() => {
updated.clear();
});

module.exports = mockCollectUpdates;
module.exports.setUpdated = setUpdated;
module.exports.collectUpdates = mockCollectUpdates;
module.exports.collectUpdates.setUpdated = setUpdated;
module.exports.collectPackages = collectPackages;
module.exports.getPackagesForOption = getPackagesForOption;
6 changes: 3 additions & 3 deletions commands/__mocks__/@lerna/conventional-commits.js
@@ -1,15 +1,15 @@
"use strict";

const fs = require.requireActual("fs-extra");
const fs = jest.requireActual("fs-extra");
const path = require("path");
const semver = require("semver");

const mockRecommendVersion = jest.fn().mockName("recommendVersion");
const mockUpdateChangelog = jest.fn().mockName("updateChangelog");

mockRecommendVersion.mockImplementation(node => semver.inc(node.version, "patch"));
mockRecommendVersion.mockImplementation((node) => semver.inc(node.version, "patch"));

mockUpdateChangelog.mockImplementation(pkg => {
mockUpdateChangelog.mockImplementation((pkg) => {
const filePath = path.join(pkg.location, "CHANGELOG.md");

// grumble grumble re-implementing the implementation
Expand Down
1 change: 0 additions & 1 deletion commands/__mocks__/@lerna/github-client.js
Expand Up @@ -6,7 +6,6 @@ const client = {
},
};

module.exports.client = client;
module.exports.createGitHubClient = () => client;
module.exports.parseGitRepo = () => ({
owner: "lerna",
Expand Down
2 changes: 1 addition & 1 deletion commands/__mocks__/@lerna/gitlab-client.js
Expand Up @@ -6,4 +6,4 @@ const client = {
},
};

module.exports = () => client;
module.exports.createGitLabClient = () => client;
4 changes: 1 addition & 3 deletions commands/__mocks__/@lerna/has-npm-version.js
@@ -1,7 +1,5 @@
"use strict";

const mockHasNpmVersion = jest.fn(() => true);
const mockMakePredicate = jest.fn(() => range => mockHasNpmVersion(range));

module.exports = mockHasNpmVersion;
module.exports.makePredicate = mockMakePredicate;
module.exports.hasNpmVersion = mockHasNpmVersion;
6 changes: 3 additions & 3 deletions commands/__mocks__/@lerna/npm-publish.js
Expand Up @@ -19,6 +19,6 @@ afterEach(() => {
registry.clear();
});

module.exports = mockNpmPublish;
module.exports.order = order;
module.exports.registry = registry;
module.exports.npmPublish = mockNpmPublish;
module.exports.npmPublish.order = order;
module.exports.npmPublish.registry = registry;
10 changes: 5 additions & 5 deletions commands/__mocks__/@lerna/output.js
@@ -1,17 +1,17 @@
"use strict";

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

// keep snapshots stable cross-platform
chalk.enabled = false;
chalk.level = 0;

// @lerna/output is just a wrapper around console.log
const mockOutput = jest.fn();

function logged() {
return mockOutput.mock.calls.map(args => multiLineTrimRight(args[0])).join("\n");
return mockOutput.mock.calls.map((args) => multiLineTrimRight(args[0])).join("\n");
}

module.exports = mockOutput;
module.exports.logged = logged;
module.exports.output = mockOutput;
module.exports.output.logged = logged;
6 changes: 3 additions & 3 deletions commands/__mocks__/@lerna/pack-directory.js
Expand Up @@ -2,7 +2,7 @@

const registry = new Set();

const mockPackDirectory = jest.fn(pkg => {
const mockPackDirectory = jest.fn((pkg) => {
registry.add(pkg.name);

return Promise.resolve({
Expand All @@ -16,5 +16,5 @@ afterEach(() => {
registry.clear();
});

module.exports = mockPackDirectory;
module.exports.registry = registry;
module.exports.packDirectory = mockPackDirectory;
module.exports.packDirectory.registry = registry;
10 changes: 5 additions & 5 deletions commands/__mocks__/@lerna/prompt.js
Expand Up @@ -15,9 +15,9 @@ const mockSelect = jest.fn((_, { choices }) => {
});
const mockInput = jest.fn(() => Promise.resolve());

exports.confirm = mockConfirm;
exports.select = mockSelect;
exports.input = mockInput;
exports.promptConfirmation = mockConfirm;
exports.promptSelectOne = mockSelect;
exports.promptTextInput = mockInput;

const semverIndex = new Map(
[
Expand All @@ -32,6 +32,6 @@ const semverIndex = new Map(
].map((keyword, idx) => [keyword, idx])
);

exports.mockChoices = (...keywords) => {
choiceIndices = keywords.map(keyword => semverIndex.get(keyword));
mockSelect.chooseBump = (keyword) => {
choiceIndices.push(semverIndex.get(keyword));
};
8 changes: 4 additions & 4 deletions commands/__mocks__/@lerna/run-lifecycle.js
@@ -1,7 +1,7 @@
"use strict";

const mockRunLifecycle = jest.fn(pkg => Promise.resolve(pkg));
const mockCreateRunner = jest.fn(opts => (pkg, stage) => {
const mockRunLifecycle = jest.fn((pkg) => Promise.resolve(pkg));
const mockCreateRunner = jest.fn((opts) => (pkg, stage) => {
// no longer the actual API, but approximates inner logic of default export
if (pkg.scripts[stage]) {
return mockRunLifecycle(pkg, stage, opts);
Expand All @@ -14,6 +14,6 @@ function getOrderedCalls() {
return mockRunLifecycle.mock.calls.map(([pkg, script]) => [pkg.name, script]);
}

module.exports = mockRunLifecycle;
module.exports.runLifecycle = mockRunLifecycle;
module.exports.createRunner = mockCreateRunner;
module.exports.getOrderedCalls = getOrderedCalls;
module.exports.runLifecycle.getOrderedCalls = getOrderedCalls;
6 changes: 3 additions & 3 deletions commands/__mocks__/load-json-file.js
Expand Up @@ -3,7 +3,7 @@
const path = require("path");
const normalizePath = require("normalize-path");

const loadJsonFile = require.requireActual("load-json-file");
const loadJsonFile = jest.requireActual("load-json-file");
const asyncRegistry = new Map();
const syncRegistry = new Map();

Expand All @@ -17,13 +17,13 @@ function incrementCalled(registry, manifestLocation) {
}

// by default, act like a spy that counts number of times each location was loaded
const mockLoadJsonFile = jest.fn(manifestLocation => {
const mockLoadJsonFile = jest.fn((manifestLocation) => {
incrementCalled(asyncRegistry, manifestLocation);

return loadJsonFile(manifestLocation);
});

const mockLoadJsonFileSync = jest.fn(manifestLocation => {
const mockLoadJsonFileSync = jest.fn((manifestLocation) => {
incrementCalled(syncRegistry, manifestLocation);

return loadJsonFile.sync(manifestLocation);
Expand Down
4 changes: 2 additions & 2 deletions commands/__mocks__/write-pkg.js
@@ -1,6 +1,6 @@
"use strict";

const writePkg = require.requireActual("write-pkg");
const writePkg = jest.requireActual("write-pkg");
const registry = new Map();

// by default, act like a spy that populates registry
Expand All @@ -10,7 +10,7 @@ const mockWritePkg = jest.fn((fp, data) => {
return writePkg(fp, data);
});

const updatedManifest = name => registry.get(name);
const updatedManifest = (name) => registry.get(name);

// a convenient format for assertions
function updatedVersions() {
Expand Down
12 changes: 6 additions & 6 deletions commands/add/__tests__/add-command.test.js
@@ -1,11 +1,11 @@
"use strict";

jest.mock("@lerna/bootstrap");
jest.mock("@evocateur/pacote/manifest");
jest.mock("pacote");

// mocked or stubbed modules
const bootstrap = require("@lerna/bootstrap");
const getManifest = require("@evocateur/pacote/manifest");
const pacote = require("pacote");

// helpers
const initFixture = require("@lerna-test/init-fixture")(__dirname);
Expand All @@ -21,7 +21,7 @@ describe("AddCommand", () => {
// we already have enough tests of BootstrapCommand
bootstrap.mockResolvedValue();
// we don't need network requests during unit tests
getManifest.mockResolvedValue({ version: "1.0.0" });
pacote.manifest.mockResolvedValue({ version: "1.0.0" });

it("should throw without packages", async () => {
const testDir = await initFixture("basic");
Expand Down Expand Up @@ -55,7 +55,7 @@ describe("AddCommand", () => {
expect(pkg3).toDependOn("tiny-tarball");
expect(pkg4).toDependOn("tiny-tarball");

expect(getManifest).toHaveBeenLastCalledWith(
expect(pacote.manifest).toHaveBeenLastCalledWith(
expect.objectContaining({
// an npm-package-arg Result
name: "tiny-tarball",
Expand Down Expand Up @@ -235,7 +235,7 @@ describe("AddCommand", () => {
it("accepts --registry option", async () => {
const testDir = await initFixture("basic");

getManifest.mockImplementationOnce(() => {
pacote.manifest.mockImplementationOnce(() => {
const err = new Error("ENOTFOUND");
return Promise.reject(err);
});
Expand All @@ -249,7 +249,7 @@ describe("AddCommand", () => {
// obviously this registry doesn't exist, thus it will always error
await expect(command).rejects.toThrow(/ENOTFOUND/);

expect(getManifest).toHaveBeenLastCalledWith(
expect(pacote.manifest).toHaveBeenLastCalledWith(
expect.objectContaining({
name: "@my-own/private-idaho",
}),
Expand Down
6 changes: 3 additions & 3 deletions commands/add/command.js
@@ -1,6 +1,6 @@
"use strict";

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

/**
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
Expand All @@ -9,7 +9,7 @@ exports.command = "add <pkg> [globs..]";

exports.describe = "Add a single dependency to matched packages";

exports.builder = yargs => {
exports.builder = (yargs) => {
yargs
.positional("pkg", {
describe: "Package name to add as a dependency",
Expand Down Expand Up @@ -66,7 +66,7 @@ exports.builder = yargs => {
.example("$0 add module-1 --no-bootstrap", "Skip automatic `lerna bootstrap`")
.example("$0 add babel-core", "Install babel-core in all modules");

return filterable(yargs);
return filterOptions(yargs);
};

exports.handler = function handler(argv) {
Expand Down

0 comments on commit 7acf883

Please sign in to comment.