SAP / generator-easy-ui5

Meta-generator various project types within the UI5 Universe
https://blogs.sap.com/2021/04/09/easy-ui5-3.0-from-community-contributions-to-community-plugins/
Apache License 2.0
235 stars 72 forks source link

yo easy-ui5 project - Fails when behind corporate proxy #79

Closed costa-satsati closed 1 year ago

costa-satsati commented 3 years ago

When behind the corporate proxy the generator fails with the following error: Failed to connect to GitHub to retrieve available repository for "ui5-community" organization! Run with --verbose for details! RequestError [HttpError]: request to https://api.github.com/orgs/ui5-community/repos failed, reason: connect ECONNREFUSED 52.63.231.178:443 at C:\Users\sattsaevk\AppData\Roaming\npm\node_modules\generator-easy-ui5\node_modules\@octokit\request\dist-node\index.js:108:11 at processTicksAndRejections (internal/process/task_queues.js:95:5) at async module.exports.prompting (C:\Users\sattsaevk\AppData\Roaming\npm\node_modules\generator-easy-ui5\generators\app\index.js:108:18) { status: 500, request: { method: 'GET', url: 'https://api.github.com/orgs/ui5-community/repos', headers: { accept: 'application/vnd.github.v3+json', 'user-agent': 'generator-easy-ui5:3.0.1 octokit-rest.js/18.6.7 octokit-core.js/3.5.1 Node.js/14.17.0 (win32; x64)' }, request: { hook: [Function: bound bound register] } } }

The 'npm config proxy ' has been added but does not solve the issue.

// create the octokit client to retrieve the generators from GH org const octokit = new Octokit({ userAgent:${this.rootGeneratorName()}:${this.rootGeneratorVersion()}, auth: this.options.ghAuthToken, });

Needs to be passed on a proxy?

vobu commented 3 years ago

yep, your guess might be spot-on: https://github.com/octokit/octokit.js#constructor-options

IObert commented 3 years ago

Hi,

thanks for opening this issue. You are right, this is currently not supported but should be easily possible with arguments that are supplied to easy-ui5.

I just got back from vacation so I don't think I'll have time for this feature this or next week (maybe after). I'll also put this out as "good first issue" in case someone wants to take care of this.

uxkjaer commented 3 years ago

The issue is not Octokit, this works fine. However yeoman has a problem with the proxy. It doesn't use the http_proxy / https_proxy env variables.

You can try cmd yo doctor and this should also fail Set the GLOBAL_AGENT_HTTP_PROXY variable to your proxy and it should work.

IObert commented 3 years ago

Interesting! Thanks @uxkjaer

attilaberencsi commented 2 years ago

Hello,

troubleshooted quite lot. After setup of GLOBAL_AGENT_HTTP_PROXY things started working, but extremely slow. 3 minutes at least until something happens behind a proxy issuing the following command.

yo easy-ui5 project --verbose

 _-----_
|       |    ╭──────────────────────────╮
|--(o)--|    │  Welcome to the easy-ui5 │

---------´ │ generator! │ ( _´U_ ) ╰──────────────────────────╯ /A\ / | ~ | __'._.' ´ |° ´ Y

Using commit 179f3e048cf243bb321ff9730abe1b0f6d5fe5fd from @ui5-community/generator-ui5-project#main... ? What do you want to do? (Use arrow keys)

Create a new OpenUI5/SAPUI5 project [app] Add a new component to an existing project [newcomponent] Add a new custom control to an existing project [newcontrol] Add a new model to an existing project [newmodel] Add a new OPA5 journey to an existing test suite [newopa5journey] Add a new OPA5 page object to an existing test suite [newopa5po] Add a new QUnit test to an existing test suite [newqunittest] (Move up and down to reveal more choices)

Looks at first look, maybe the Git access takes time ? Using Git Bash however takes 2 seconds to fetch a complete repository. If you need more input let me know, how I can activate some logging or debug-info which might help the analyzis, where the timeis spent. Thanks

IObert commented 2 years ago

Thanks for your comment. I got to say that I'm not sure how to deal with this situation :(

Is it possible that your proxy has a limited bandwidth and that this is the reason? Can you try to run yo doctor or test other yeoman generators to see if there are similar problems?

softshipper commented 2 years ago

I also have the same issue. The error messages come from the library @octokit/rest, because it tries to download the repository generator-ui5-project from github not through the proxy that was set with statement npm config set proxy https://..... I have created an application that illustrates the problem:

import { Octokit } from "@octokit/rest";
import { HttpProxyAgent } from "http-proxy-agent";
import { retry } from "@octokit/plugin-retry";

const ghOrg = "ui5-community",
    repoName = "generator-ui5-project",
    branch = "main";

const RetryOctokit = Octokit.plugin(retry);
const octokit = new RetryOctokit({
    log: {
        debug: console.log,
        info: console.log,
        warn: console.log,
        error: console.log,
    },
    userAgent: "generator-easy-ui5"
});

octokit.repos.getBranch({
    owner: ghOrg,
    repo: repoName,
    branch,
}).then(console.log)
    .catch(e => {
        console.error("#################### ERROR ####################");
        console.log(e);
    });

@IObert Why do you need to download the repo generator-ui5-project during the installation of npm install -g yo generator-easy-ui5?

Thanks

IObert commented 2 years ago

This repo contains the actual logic used to scaffhold new UI5 projects. And as this is the common use-case to download easy-ui5, it happens automatically after easy-ui5 has been installed.

softshipper commented 2 years ago

@IObert What is your suggestion? How should we solve it?

IObert commented 2 years ago

It's great that you were able to provide a minimal code sample to reproduce the issue. I have to say that I never saw such a problem and I still suspect this is cause by the configuration of your local network or GitHub. But not from EasyUI5 directly.

And as EasyUI5 is not an official tool by SAP (it's just an open source project that is maintained by SAP. If you are looking for a tool with a "guarantueed by SAP" label, you might be intersted in the SAP Fiori tools), I would ask you to find a fix (if possible) and document it here or even provide a pull request to avoid this in the future.

petermuessig commented 2 years ago

IMO, we should make the node proxy configuration available to the internally used Octokit APIs. I'll try to investigate this asap.