Skip to content

Commit

Permalink
feat: Migrate existing usage to libnpm
Browse files Browse the repository at this point in the history
Incremental progress toward #1767

* libnpmaccess -> libnpm/access
* npm-lifecycle -> libnpm/run-script
* npm-package-arg -> libnpm/parse-arg
* npmlog -> libnpm/log
* pacote.manifest -> libnpm/manifest
* pacote.packument -> libnpm/packument
* manually hoist find-up@3
  • Loading branch information
evocateur committed Dec 7, 2018
1 parent 732d850 commit 0d3a786
Show file tree
Hide file tree
Showing 99 changed files with 639 additions and 234 deletions.
6 changes: 3 additions & 3 deletions commands/add/index.js
@@ -1,10 +1,10 @@
"use strict";

const dedent = require("dedent");
const npa = require("npm-package-arg");
const npa = require("libnpm/parse-arg");
const pMap = require("p-map");
const path = require("path");
const pacote = require("pacote");
const getManifest = require("libnpm/manifest");
const semver = require("semver");

const Command = require("@lerna/command");
Expand Down Expand Up @@ -178,7 +178,7 @@ class AddCommand extends Command {
registry: this.options.registry,
});

return pacote.manifest(this.spec, opts).then(pkg => pkg.version);
return getManifest(this.spec, opts).then(pkg => pkg.version);
}

packageSatisfied() {
Expand Down
2 changes: 1 addition & 1 deletion commands/add/lib/get-range-to-reference.js
@@ -1,6 +1,6 @@
"use strict";

const npa = require("npm-package-arg");
const npa = require("libnpm/parse-arg");
const path = require("path");
const semver = require("semver");

Expand Down
3 changes: 1 addition & 2 deletions commands/add/package.json
Expand Up @@ -38,9 +38,8 @@
"@lerna/npm-conf": "file:../../utils/npm-conf",
"@lerna/validation-error": "file:../../core/validation-error",
"dedent": "^0.7.0",
"npm-package-arg": "^6.0.0",
"libnpm": "^2.0.1",
"p-map": "^1.2.0",
"pacote": "^9.1.0",
"semver": "^5.5.0"
}
}
2 changes: 1 addition & 1 deletion commands/bootstrap/index.js
Expand Up @@ -2,7 +2,7 @@

const dedent = require("dedent");
const getPort = require("get-port");
const npa = require("npm-package-arg");
const npa = require("libnpm/parse-arg");
const path = require("path");
const pFinally = require("p-finally");
const pMap = require("p-map");
Expand Down
2 changes: 1 addition & 1 deletion commands/bootstrap/lib/has-dependency-installed.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const readPackageTree = require("read-package-tree");
const semver = require("semver");

Expand Down
3 changes: 1 addition & 2 deletions commands/bootstrap/package.json
Expand Up @@ -50,9 +50,8 @@
"@lerna/validation-error": "file:../../core/validation-error",
"dedent": "^0.7.0",
"get-port": "^3.2.0",
"libnpm": "^2.0.1",
"multimatch": "^2.1.0",
"npm-package-arg": "^6.0.0",
"npmlog": "^4.1.2",
"p-finally": "^1.0.0",
"p-map": "^1.2.0",
"p-map-series": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions commands/create/index.js
Expand Up @@ -7,7 +7,7 @@ const { URL } = require("whatwg-url");
const camelCase = require("camelcase");
const dedent = require("dedent");
const initPackageJson = require("pify")(require("init-package-json"));
const npa = require("npm-package-arg");
const npa = require("libnpm/parse-arg");
const slash = require("slash");

const Command = require("@lerna/command");
Expand Down Expand Up @@ -49,7 +49,7 @@ class CreateCommand extends Command {
yes,
} = this.options;

// npm-package-arg handles all the edge-cases with scopes
// libnpm/parse-arg handles all the edge-cases with scopes
const { name, scope } = npa(pkgName);

// optional scope is _not_ included in the directory name
Expand Down
2 changes: 1 addition & 1 deletion commands/create/lib/lerna-module-data.js
Expand Up @@ -28,7 +28,7 @@ We exploit this fact to avoid eslint breaking on the reserved word.

const validateLicense = require("validate-npm-package-license");
const validateName = require("validate-npm-package-name");
const npa = require("npm-package-arg");
const npa = require("libnpm/parse-arg");
const semver = require("semver");

const niceName = rudeName =>
Expand Down
2 changes: 1 addition & 1 deletion commands/create/package.json
Expand Up @@ -41,7 +41,7 @@
"fs-extra": "^7.0.0",
"globby": "^8.0.1",
"init-package-json": "^1.10.3",
"npm-package-arg": "^6.0.0",
"libnpm": "^2.0.1",
"pify": "^3.0.0",
"semver": "^5.5.0",
"slash": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion commands/diff/lib/get-last-commit.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = getLastCommit;
Expand Down
2 changes: 1 addition & 1 deletion commands/diff/lib/has-commit.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = hasCommit;
Expand Down
2 changes: 1 addition & 1 deletion commands/diff/package.json
Expand Up @@ -35,6 +35,6 @@
"@lerna/child-process": "file:../../core/child-process",
"@lerna/command": "file:../../core/command",
"@lerna/validation-error": "file:../../core/validation-error",
"npmlog": "^4.1.2"
"libnpm": "^2.0.1"
}
}
6 changes: 3 additions & 3 deletions commands/publish/__tests__/get-unpublished-packages.test.js
@@ -1,13 +1,13 @@
"use strict";

jest.mock("pacote");
jest.mock("libnpm/packument");

const pacote = require("pacote");
const getPackument = require("libnpm/packument");
const Project = require("@lerna/project");
const initFixture = require("@lerna-test/init-fixture")(__dirname);
const getUnpublishedPackages = require("../lib/get-unpublished-packages");

pacote.packument.mockImplementation(async pkg => {
getPackument.mockImplementation(async pkg => {
if (pkg === "package-1") {
return {
versions: {},
Expand Down
4 changes: 2 additions & 2 deletions commands/publish/__tests__/verify-npm-package-access.test.js
@@ -1,8 +1,8 @@
"use strict";

jest.mock("libnpmaccess");
jest.mock("libnpm/access");

const access = require("libnpmaccess");
const access = require("libnpm/access");
const { getPackages } = require("@lerna/project");
const loggingOutput = require("@lerna-test/logging-output");
const initFixture = require("@lerna-test/init-fixture")(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/get-current-sha.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = getCurrentSHA;
Expand Down
4 changes: 2 additions & 2 deletions commands/publish/lib/get-current-tags.js
@@ -1,7 +1,7 @@
"use strict";

const log = require("npmlog");
const npa = require("npm-package-arg");
const log = require("libnpm/log");
const npa = require("libnpm/parse-arg");
const childProcess = require("@lerna/child-process");

module.exports = getCurrentTags;
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/get-npm-username.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const fetch = require("npm-registry-fetch");
const ValidationError = require("@lerna/validation-error");

Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/get-tagged-packages.js
@@ -1,7 +1,7 @@
"use strict";

const path = require("path");
const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = getTaggedPackages;
Expand Down
6 changes: 3 additions & 3 deletions commands/publish/lib/get-unpublished-packages.js
@@ -1,8 +1,8 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const pReduce = require("p-reduce");
const pacote = require("pacote");
const getPackument = require("libnpm/packument");

module.exports = getUnpublishedPackages;

Expand All @@ -12,7 +12,7 @@ function getUnpublishedPackages(project, opts) {
let chain = Promise.resolve();

const mapper = (unpublished, pkg) =>
pacote.packument(pkg.name, opts.snapshot).then(
getPackument(pkg.name, opts.snapshot).then(
packument => {
if (packument.versions[pkg.version] === undefined) {
unpublished.push(pkg);
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/git-checkout.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = gitCheckout;
Expand Down
4 changes: 2 additions & 2 deletions commands/publish/lib/verify-npm-package-access.js
@@ -1,7 +1,7 @@
"use strict";

const log = require("npmlog");
const access = require("libnpmaccess");
const log = require("libnpm/log");
const access = require("libnpm/access");
const RegistryConfig = require("npm-registry-fetch/config");
const ValidationError = require("@lerna/validation-error");

Expand Down
5 changes: 1 addition & 4 deletions commands/publish/package.json
Expand Up @@ -49,15 +49,12 @@
"@lerna/validation-error": "file:../../core/validation-error",
"@lerna/version": "file:../version",
"fs-extra": "^7.0.0",
"libnpmaccess": "^3.0.0",
"npm-package-arg": "^6.0.0",
"libnpm": "^2.0.1",
"npm-registry-fetch": "^3.8.0",
"npmlog": "^4.1.2",
"p-finally": "^1.0.0",
"p-map": "^1.2.0",
"p-pipe": "^1.2.0",
"p-reduce": "^1.0.0",
"pacote": "^9.1.0",
"semver": "^5.5.0"
}
}
2 changes: 1 addition & 1 deletion commands/version/command.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const semver = require("semver");

/**
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/get-current-branch.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = currentBranch;
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/git-add.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const path = require("path");
const slash = require("slash");
const childProcess = require("@lerna/child-process");
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/git-commit.js
@@ -1,7 +1,7 @@
"use strict";

const { EOL } = require("os");
const log = require("npmlog");
const log = require("libnpm/log");
const tempWrite = require("temp-write");
const childProcess = require("@lerna/child-process");

Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/git-push.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = gitPush;
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/git-tag.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = gitTag;
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/is-anything-committed.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = isAnythingCommitted;
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/is-behind-upstream.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = isBehindUpstream;
Expand Down
2 changes: 1 addition & 1 deletion commands/version/lib/remote-branch-exists.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const childProcess = require("@lerna/child-process");

module.exports = remoteBranchExists;
Expand Down
2 changes: 1 addition & 1 deletion commands/version/package.json
Expand Up @@ -44,8 +44,8 @@
"@lerna/validation-error": "file:../../core/validation-error",
"chalk": "^2.3.1",
"dedent": "^0.7.0",
"libnpm": "^2.0.1",
"minimatch": "^3.0.4",
"npmlog": "^4.1.2",
"p-map": "^1.2.0",
"p-pipe": "^1.2.0",
"p-reduce": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion core/cli/index.js
@@ -1,7 +1,7 @@
"use strict";

const dedent = require("dedent");
const log = require("npmlog");
const log = require("libnpm/log");
const yargs = require("yargs/yargs");
const globalOptions = require("@lerna/global-options");

Expand Down
2 changes: 1 addition & 1 deletion core/cli/package.json
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@lerna/global-options": "file:../global-options",
"dedent": "^0.7.0",
"npmlog": "^4.1.2",
"libnpm": "^2.0.1",
"yargs": "^12.0.1"
}
}
2 changes: 1 addition & 1 deletion core/command/__tests__/command.test.js
Expand Up @@ -3,7 +3,7 @@
"use strict";

const fs = require("fs-extra");
const log = require("npmlog");
const log = require("libnpm/log");
const path = require("path");
const tempy = require("tempy");

Expand Down
2 changes: 1 addition & 1 deletion core/command/index.js
Expand Up @@ -3,7 +3,7 @@
const _ = require("lodash");
const dedent = require("dedent");
const execa = require("execa");
const log = require("npmlog");
const log = require("libnpm/log");

const PackageGraph = require("@lerna/package-graph");
const Project = require("@lerna/project");
Expand Down
2 changes: 1 addition & 1 deletion core/command/lib/log-package-error.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");

module.exports = logPackageError;

Expand Down
2 changes: 1 addition & 1 deletion core/command/lib/warn-if-hanging.js
@@ -1,6 +1,6 @@
"use strict";

const log = require("npmlog");
const log = require("libnpm/log");
const ChildProcessUtilities = require("@lerna/child-process");

module.exports = warnIfHanging;
Expand Down
4 changes: 2 additions & 2 deletions core/command/package.json
Expand Up @@ -39,7 +39,7 @@
"dedent": "^0.7.0",
"execa": "^1.0.0",
"is-ci": "^1.0.10",
"lodash": "^4.17.5",
"npmlog": "^4.1.2"
"libnpm": "^2.0.1",
"lodash": "^4.17.5"
}
}

0 comments on commit 0d3a786

Please sign in to comment.