Fix: Extension version fallback to github support for `~` and `^` (#4099)

* Fix github fallback package with range

* Wip

* Wip

* ./
This commit is contained in:
Timothee Guerin 2021-04-26 11:20:08 -07:00 коммит произвёл GitHub
Родитель 415a486cc8
Коммит 3cd141b908
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 32 добавлений и 10 удалений

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@autorest/configuration",
"comment": "**Bump** @autorest/java default version to 4.0.24",
"type": "patch"
}
],
"packageName": "@autorest/configuration",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@azure-tools/extension",
"comment": "**Fix** Fallback to github release when version doesn't exists broken if using version range",
"type": "patch"
}
],
"packageName": "@azure-tools/extension",
"email": "tiguerin@microsoft.com"
}

Просмотреть файл

@ -2,17 +2,17 @@
The V3 version of the Java Generator.
``` yaml $(java) && !$(legacy) && !$(v2) && !isRequested('@microsoft.azure/autorest.java')
```yaml $(java) && !$(legacy) && !$(v2) && !isRequested('@microsoft.azure/autorest.java')
version: ~3.1.0
use-extension:
"@autorest/java": "^4.0.4"
"@autorest/java": "^4.0.24"
try-require: ./readme.java.md
```
Enable use of the V2 Java generator (and V2 core) with the `--legacy` or `--v2` parameter:
``` yaml $(java) && ($(legacy) || $(v2) || isRequested('@microsoft.azure/autorest.java'))
```yaml $(java) && ($(legacy) || $(v2) || isRequested('@microsoft.azure/autorest.java'))
# default the v2 generator to using the last stable @microsoft.azure/autorest-core
version: ~2.0.4413

Просмотреть файл

@ -232,13 +232,13 @@ export class ExtensionManager {
// (if it is an autorest.<whatever> project)
// https://github.com/Azure/${PROJECT}/releases/download/v${VERSION}/autorest/${PROJECT}-${VERSION}.tgz
if (name.startsWith("@autorest/")) {
const ghurl = `https://github.com/Azure/${name.replace(
"@autorest/",
"autorest.",
)}/releases/download/v${version}/${name.replace("@", "").replace("autorest/", "autorest-")}-${version.replace(
/_/g,
"-",
)}.tgz`;
const githubRepo = name.replace("@autorest/", "autorest.");
const githubPkgName = name.replace("@", "").replace("autorest/", "autorest-");
const githubVersion = version
.replace(/^[~|^]/g, "") // Use the exact version instead of range
.replace(/_/g, "-"); // Replace _ with - ;
const ghurl = `https://github.com/Azure/${githubRepo}/releases/download/v${githubVersion}/${githubPkgName}-${githubVersion}.tgz`;
try {
const pm = await fetchPackageMetadata(ghurl);
if (pm) {