How to use the @yarnpkg/plugin-npm.npmHttpUtils.put function in @yarnpkg/plugin-npm

To help you get started, we’ve selected a few @yarnpkg/plugin-npm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yarnpkg / berry / packages / plugin-npm-cli / sources / commands / npm / login.ts View on Github external
}, async report => {
      const credentials = await getCredentials(prompt);
      const url = `/-/user/org.couchdb.user:${encodeURIComponent(credentials.name)}`;

      try {
        const response = await npmHttpUtils.put(url, credentials, {
          configuration,
          registry,
          json: true,
          authType: npmHttpUtils.AuthType.NO_AUTH,
        });

        // @ts-ignore
        await setAuthToken(registry, response.token, {configuration});

        return report.reportInfo(MessageName.UNNAMED, `Successfully logged in`);
      } catch (error) {
        return report.reportError(MessageName.AUTHENTICATION_INVALID, `Invalid Authentication`);
      }
    });
github yarnpkg / berry / packages / plugin-npm-cli / sources / commands / npm / publish.ts View on Github external
await packUtils.prepareForPack(workspace, {report}, async () => {
        const files = await packUtils.genPackList(workspace);

        for (const file of files)
          report.reportInfo(null, file);

        const pack = await packUtils.genPackStream(workspace, files);
        const buffer = await miscUtils.bufferStream(pack);

        const body = await makePublishBody(workspace, buffer, {
          access: this.access,
          tag: this.tag,
        });

        try {
          await npmHttpUtils.put(npmHttpUtils.getIdentUrl(ident), body, {
            configuration,
            registry,
            json: true,
          });
        } catch (error) {
          if (error.name !== `HTTPError`) {
            throw error;
          } else {
            const message = error.response.body && error.body.response.error
              ? error.response.body.error
              : `The remote server answered with HTTP ${error.response.statusCode} ${error.response.statusMessage}`;

            report.reportError(MessageName.NETWORK_ERROR, message);
          }
        }
      });