Skip to content

Commit

Permalink
chore: deps updates (#3715)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Jun 7, 2023
1 parent aca9efc commit 5095b04
Show file tree
Hide file tree
Showing 22 changed files with 1,159 additions and 1,687 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -117,7 +117,7 @@ jobs:
# Ignored specs currently failing on windows
# TODO: investigate why
npx nx run-many -t test --parallel=3 --ci --maxWorkers=2 --testTimeout=60000 --testPathIgnorePatterns=import-command.spec.ts &
npx nx run-many -t test --parallel=3 --ci --maxWorkers=2 --testTimeout=60000 --testPathIgnorePatterns=import-command.spec.ts --testPathIgnorePatterns=save.spec.ts --testPathIgnorePatterns=find-file.spec.ts --testPathIgnorePatterns=chain-class.spec.ts &
pids+=($!)
Expand Down
118 changes: 0 additions & 118 deletions a.json

This file was deleted.

28 changes: 14 additions & 14 deletions libs/commands/publish/src/lib/verify-npm-package-access.spec.ts
Expand Up @@ -8,7 +8,7 @@ const initFixture = initFixtureFactory(__dirname);

import { verifyNpmPackageAccess } from "./verify-npm-package-access";

access.lsPackages.mockImplementation(() =>
access.getPackages.mockImplementation(() =>
Promise.resolve({
"package-1": "read-write",
"package-2": "read-write",
Expand Down Expand Up @@ -38,7 +38,7 @@ describe("verifyNpmPackageAccess", () => {

await verifyNpmPackageAccess(packages, "lerna-test", opts);

expect(access.lsPackages).toHaveBeenLastCalledWith(
expect(access.getPackages).toHaveBeenLastCalledWith(
"lerna-test",
expect.objectContaining({
registry: "https://registry.npmjs.org/",
Expand All @@ -51,7 +51,7 @@ describe("verifyNpmPackageAccess", () => {
const packages = await getPackages(cwd);
const opts = { registry: "https://registry.npmjs.org/" };

access.lsPackages.mockImplementationOnce(() =>
access.getPackages.mockImplementationOnce(() =>
Promise.resolve({
"package-1": "read-write",
// unpublished packages don't show up in ls-packages
Expand All @@ -61,16 +61,16 @@ describe("verifyNpmPackageAccess", () => {

await verifyNpmPackageAccess(packages, "lerna-test", opts);

expect(access.lsPackages).toHaveBeenCalled();
expect(access.getPackages).toHaveBeenCalled();
});

test("allows null result to pass with warning", async () => {
test("allows no results to pass with warning", async () => {
const packages = await getPackages(cwd);
const opts = { registry: "https://registry.npmjs.org/" };

access.lsPackages.mockImplementationOnce(() =>
// access.lsPackages() returns null when _no_ results returned
Promise.resolve(null)
access.getPackages.mockImplementationOnce(() =>
// access.getPackages() returns an empty object when no results returned
Promise.resolve({})
);

await verifyNpmPackageAccess(packages, "lerna-test", opts);
Expand All @@ -85,7 +85,7 @@ describe("verifyNpmPackageAccess", () => {
const packages = await getPackages(cwd);
const opts = { registry: "https://registry.npmjs.org/" };

access.lsPackages.mockImplementationOnce(() =>
access.getPackages.mockImplementationOnce(() =>
Promise.resolve({
"package-1": "read-write",
"package-2": "read-only",
Expand All @@ -102,7 +102,7 @@ describe("verifyNpmPackageAccess", () => {
const registry = "http://outdated-npm-enterprise.mycompany.com:12345/";
const opts = { registry };

access.lsPackages.mockImplementationOnce(() => {
access.getPackages.mockImplementationOnce(() => {
const err = new Error("npm-enterprise-what") as any;
err.code = "E500";
return Promise.reject(err);
Expand All @@ -112,7 +112,7 @@ describe("verifyNpmPackageAccess", () => {

const [logMessage] = loggingOutput("warn");
expect(logMessage).toMatch(
`Registry "${registry}" does not support \`npm access ls-packages\`, skipping permission checks...`
`Registry "${registry}" does not support \`npm access list packages\`, skipping permission checks...`
);
expect(console.error).not.toHaveBeenCalled();
});
Expand All @@ -122,7 +122,7 @@ describe("verifyNpmPackageAccess", () => {
const registry = "https://artifactory-partial-implementation.corpnet.mycompany.com/";
const opts = { registry };

access.lsPackages.mockImplementationOnce(() => {
access.getPackages.mockImplementationOnce(() => {
const err = new Error("artifactory-why") as any;
err.code = "E404";
return Promise.reject(err);
Expand All @@ -132,7 +132,7 @@ describe("verifyNpmPackageAccess", () => {

const [logMessage] = loggingOutput("warn");
expect(logMessage).toMatch(
`Registry "${registry}" does not support \`npm access ls-packages\`, skipping permission checks...`
`Registry "${registry}" does not support \`npm access list packages\`, skipping permission checks...`
);
expect(console.error).not.toHaveBeenCalled();
});
Expand All @@ -141,7 +141,7 @@ describe("verifyNpmPackageAccess", () => {
const packages = await getPackages(cwd);
const opts = {};

access.lsPackages.mockImplementationOnce(() => {
access.getPackages.mockImplementationOnce(() => {
const err = new Error("gonna-need-a-bigger-boat");

return Promise.reject(err);
Expand Down
28 changes: 14 additions & 14 deletions libs/commands/publish/src/lib/verify-npm-package-access.ts
Expand Up @@ -18,35 +18,35 @@ export function verifyNpmPackageAccess(

opts.log.silly("verifyNpmPackageAccess", "");

return pulseTillDone(access.lsPackages(username, opts)).then(success, failure);
return pulseTillDone(access.getPackages(username, opts)).then(success, failure);

function success(result) {
// when _no_ results received, access.lsPackages returns null
// we can only assume that the packages in question have never been published
if (result === null) {
const userPackages = Object.keys(result || {});
if (userPackages.length === 0) {
opts.log.warn(
"",
"The logged-in user does not have any previously-published packages, skipping permission checks..."
);
} else {
for (const pkg of packages) {
if (pkg.name in result && result[pkg.name] !== "read-write") {
throw new ValidationError(
"EACCESS",
`You do not have write permission required to publish "${pkg.name}"`
);
}
return;
}

for (const pkg of packages) {
if (pkg.name in result && result[pkg.name] !== "read-write") {
throw new ValidationError(
"EACCESS",
`You do not have write permission required to publish "${pkg.name}"`
);
}
}
}

function failure(err) {
// pass if registry does not support ls-packages endpoint
// pass if registry does not support the package endpoint
if (err.code === "E500" || err.code === "E404") {
// most likely a private registry (npm Enterprise, verdaccio, etc)
opts.log.warn(
"EREGISTRY",
"Registry %j does not support `npm access ls-packages`, skipping permission checks...",
"Registry %j does not support `npm access list packages`, skipping permission checks...",
// registry
opts.registry
);
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/lib/npm-conf/conf.ts
Expand Up @@ -9,7 +9,7 @@ import { toNerfDart } from "./nerf-dart";

// config-chain does not have types
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ConfigChain } = require("config-chain");
const { ConfigChain } = require("./config-chain");

export class Conf extends ConfigChain {
root: any;
Expand Down

0 comments on commit 5095b04

Please sign in to comment.