Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove VoloRegistry from NpmrcFile #11265

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ private async Task CreateNpmrcFileAsync(string directoryName)
{
var fileName = Path.Combine(directoryName, ".npmrc");
var abpRegistry = "@abp:registry=https://www.myget.org/F/abp-nightly/npm";
var voloRegistry = await GetVoloRegistryAsync();

if (await NpmrcFileExistAsync(directoryName))
{
Expand All @@ -132,11 +131,6 @@ private async Task CreateNpmrcFileAsync(string directoryName)
fileContent += Environment.NewLine + abpRegistry;
}

if (!fileContent.Contains(voloRegistry))
{
fileContent += Environment.NewLine + voloRegistry;
}

File.WriteAllText(fileName, fileContent);

return;
Expand All @@ -145,42 +139,10 @@ private async Task CreateNpmrcFileAsync(string directoryName)
using var fs = File.Create(fileName);

var content = new UTF8Encoding(true)
.GetBytes(abpRegistry + Environment.NewLine + voloRegistry);
.GetBytes(abpRegistry);
fs.Write(content, 0, content.Length);
}

private async Task<string> GetVoloRegistryAsync()
{
var apikey = await GetApiKeyAsync();

if (string.IsNullOrWhiteSpace(apikey))
{
return "";
}

return "@volo:registry=https://www.myget.org/F/abp-commercial/auth/" + apikey + "/npm/";
}

public async Task<string> GetApiKeyAsync()
{
try
{
var client = _cliHttpClientFactory.CreateClient();
using (var response = await client.GetHttpResponseMessageWithRetryAsync(
url: $"{CliUrls.WwwAbpIo}api/myget/apikey/",
cancellationToken: CancellationTokenProvider.Token,
logger: Logger
))
{
return Encoding.Default.GetString(await response.Content.ReadAsByteArrayAsync());
}
}
catch (Exception)
{
return string.Empty;
}
}

private static bool IsAngularProject(string fileDirectory)
{
return File.Exists(Path.Combine(fileDirectory, "angular.json"));
Expand Down