Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 199 forks source link

Support for Proxy #2429

Open a1626 opened 7 years ago

a1626 commented 7 years ago

Description

Disclaimer: This might be similar to #201. Is there support in cli to proxy calls to api.github.com? If not, is there any other way to proxy same. Or is there any near future plan to add the same, as a lot of polymer users will be behind some sort of firewall. IMHO cloning the template manually and then working on it beats the purpose of cli.

Just to add, this will only happen for default templates. New templates can be downloaded and installed easily using npmrc file.

Versions & Environment

Actual Results

Stack trace for shop template from terminal: info: Running template shop... info: Finding latest ^1.0.0 release of Polymer/shop error: Uncaught exception: getaddrinfo ENOTFOUND api.github.com api.github.com:443 error: Error: getaddrinfo ENOTFOUND api.github.com api.github.com:443 at __dirname.sendError (/usr/local/lib/node_modules/polymer-cli/node_modules/github/lib/index.js:838:19) at /usr/local/lib/node_modules/polymer-cli/node_modules/github/lib/index.js:849:29 at callCallback (/usr/local/lib/node_modules/polymer-cli/node_modules/github/lib/index.js:713:17) at ClientRequest. (/usr/local/lib/node_modules/polymer-cli/node_modules/github/lib/index.js:791:17) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at TLSSocket.socketErrorListener (_http_client.js:310:9) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at connectErrorNT (net.js:1022:8)

Result of api.github.com from browser: { "current_user_url": "https://api.github.com/user", "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}", "authorizations_url": "https://api.github.com/authorizations", "code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}", "commit_search_url": "https://api.github.com/search/commits?q={query}{&page,per_page,sort,order}", "emails_url": "https://api.github.com/user/emails", "emojis_url": "https://api.github.com/emojis", "events_url": "https://api.github.com/events", "feeds_url": "https://api.github.com/feeds", "followers_url": "https://api.github.com/user/followers", "following_url": "https://api.github.com/user/following{/target}", "gists_url": "https://api.github.com/gists{/gist_id}", "hub_url": "https://api.github.com/hub", "issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}", "issues_url": "https://api.github.com/issues", "keys_url": "https://api.github.com/user/keys", "notifications_url": "https://api.github.com/notifications", "organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}", "organization_url": "https://api.github.com/orgs/{org}", "public_gists_url": "https://api.github.com/gists/public", "rate_limit_url": "https://api.github.com/rate_limit", "repository_url": "https://api.github.com/repos/{owner}/{repo}", "repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}", "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}", "starred_url": "https://api.github.com/user/starred{/owner}{/repo}", "starred_gists_url": "https://api.github.com/gists/starred", "team_url": "https://api.github.com/teams", "user_url": "https://api.github.com/users/{user}", "user_organizations_url": "https://api.github.com/user/orgs", "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}", "user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}" }

FredKSchott commented 7 years ago

I'd be happy to review a PR to add support for this, or (easier) to add helpful output to this error to point the user to the github URL where they can download the template themselves.

a1626 commented 7 years ago

@FredKSchott can you help me with something

In github.ts line24 it's written that

this._github = opts.githubApi || new GitHubApi

Is there any condition where githubApi is fetched from opts ? I've not been able to find any case from the code, but wanted to confirm with you once.

So far i've been able to proxy the calls by hard coding the proxy url. Next, i was trying to work with environment variables, but the problem there is getReleases method which does not seems to use request module and thus environment variables.

I'm thinking of moving proxy configuration to external file (like gitconfig) as first option and if not then adding another argument to be passed along from cli.

FredKSchott commented 7 years ago

That is currently only used for testing, check out the tests to see where different shims are passed in via options.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.