2022-03-23 03:07:57 +03:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
|
|
import { fail } from 'assert';
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
import { Artifact, parseArtifactDependency } from '../artifacts/artifact';
|
|
|
|
import { artifactIdentity } from '../cli/format';
|
2022-03-23 03:07:57 +03:00
|
|
|
import { i } from '../i18n';
|
|
|
|
import { Session } from '../session';
|
|
|
|
import { Uri } from '../util/uri';
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
import { LocalRegistry } from './LocalRegistry';
|
|
|
|
import { RemoteRegistry } from './RemoteRegistry';
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
export interface SearchCriteria {
|
|
|
|
idOrShortName?: string;
|
|
|
|
version?: string;
|
|
|
|
keyword?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// In general, a Registry or RegistryResolverContext
|
|
|
|
export interface ArtifactSearchable {
|
|
|
|
// Returns [artifactId, artifactsOfMatchingVersionsOfThatId][]
|
|
|
|
search(criteria?: SearchCriteria): Promise<Array<[string, Array<Artifact>]>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Registry extends ArtifactSearchable {
|
|
|
|
readonly count: number;
|
|
|
|
readonly location: Uri;
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
load(force?: boolean): Promise<void>;
|
|
|
|
save(): Promise<void>;
|
2023-05-08 21:37:21 +03:00
|
|
|
update(displayName?: string): Promise<void>;
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
regenerate(normalize?: boolean): Promise<void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns an artifact for the strongly-named artifact id/version.
|
|
|
|
*/
|
|
|
|
export async function getArtifact(registry: ArtifactSearchable, idOrShortName: string, version: string | undefined): Promise<[string, Artifact] | undefined> {
|
|
|
|
const artifactRecords = await registry.search({ idOrShortName, version });
|
|
|
|
if (artifactRecords.length === 0) {
|
|
|
|
return undefined; // nothing matched.
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
if (artifactRecords.length === 1) {
|
|
|
|
// found 1 matching artifact identity
|
|
|
|
const artifactRecord = artifactRecords[0];
|
|
|
|
const artifactDisplay = artifactRecord[0];
|
|
|
|
const artifactVersions = artifactRecord[1];
|
|
|
|
if (artifactVersions.length === 0) {
|
|
|
|
throw new Error('Internal search error: id matched but no versions present');
|
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
return [artifactDisplay, artifactVersions[0]];
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
// multiple matches.
|
|
|
|
// we can't return a single artifact, we're going to have to throw.
|
|
|
|
fail(i`'${idOrShortName}' matched more than one result (${[...artifactRecords.map(each => each[0])].join(',')}).`);
|
|
|
|
}
|
|
|
|
|
|
|
|
export class RegistryDatabase {
|
|
|
|
#uriToRegistry: Map<string, Registry> = new Map();
|
|
|
|
|
|
|
|
getRegistryByUri(registryUri: string) {
|
|
|
|
return this.#uriToRegistry.get(registryUri);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
has(registryUri: string) { return this.#uriToRegistry.has(registryUri); }
|
|
|
|
|
|
|
|
// Exposed for testing
|
|
|
|
add(uri: Uri, registry: Registry) {
|
|
|
|
const stringized = uri.toString();
|
|
|
|
if (this.#uriToRegistry.has(stringized)) {
|
|
|
|
throw new Error(`Duplicate registry add ${stringized}`);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
|
|
|
|
this.#uriToRegistry.set(stringized, registry);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
async loadRegistry(session: Session, locationUri: Uri): Promise<Registry> {
|
|
|
|
const locationUriStr = locationUri.toString();
|
|
|
|
const existingRegistry = this.#uriToRegistry.get(locationUriStr);
|
|
|
|
if (existingRegistry) {
|
|
|
|
return existingRegistry;
|
|
|
|
}
|
|
|
|
|
|
|
|
// not already loaded
|
|
|
|
let loaded: Registry;
|
|
|
|
switch (locationUri.scheme) {
|
|
|
|
case 'https':
|
|
|
|
loaded = new RemoteRegistry(session, locationUri);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'file':
|
|
|
|
loaded = new LocalRegistry(session, locationUri);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new Error(i`Unsupported registry scheme '${locationUri.scheme}'`);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.#uriToRegistry.set(locationUriStr, loaded);
|
|
|
|
await loaded.load();
|
|
|
|
return loaded;
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
2023-05-08 21:37:21 +03:00
|
|
|
|
|
|
|
getAllUris() {
|
|
|
|
return Array.from(this.#uriToRegistry.keys());
|
|
|
|
}
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
// When a registry resolver is used to map a URI back to some form of for-display-purposes-only name.
|
|
|
|
export interface RegistryDisplayContext {
|
|
|
|
getRegistryDisplayName(registry: Uri): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class RegistryResolver implements RegistryDisplayContext {
|
|
|
|
readonly #database: RegistryDatabase;
|
|
|
|
readonly #knownUris: Set<string>;
|
|
|
|
readonly #uriToName: Map<string, string>;
|
|
|
|
readonly #nameToUri: Map<string, string>;
|
|
|
|
|
|
|
|
private addMapping(name: string, uri: string) {
|
|
|
|
this.#uriToName.set(uri, name);
|
|
|
|
this.#nameToUri.set(name, uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(parent: RegistryDatabase | RegistryResolver) {
|
|
|
|
if (parent instanceof RegistryResolver) {
|
|
|
|
this.#database = parent.#database;
|
|
|
|
this.#knownUris = new Set(parent.#knownUris);
|
|
|
|
this.#uriToName = new Map(parent.#uriToName);
|
|
|
|
this.#nameToUri = new Map(parent.#nameToUri);
|
|
|
|
} else {
|
|
|
|
this.#database = parent;
|
|
|
|
this.#knownUris = new Set();
|
|
|
|
this.#uriToName = new Map();
|
|
|
|
this.#nameToUri = new Map();
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
getRegistryName(registry: Uri): string | undefined {
|
|
|
|
const stringized = registry.toString();
|
|
|
|
return this.#uriToName.get(stringized);
|
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
getRegistryDisplayName(registry: Uri): string {
|
|
|
|
const stringized = registry.toString();
|
|
|
|
const prettyName = this.#uriToName.get(stringized);
|
|
|
|
if (prettyName) {
|
|
|
|
return prettyName;
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
return `[${stringized}]`;
|
|
|
|
}
|
|
|
|
|
|
|
|
getRegistryByUri(registryUri: Uri): Registry | undefined {
|
|
|
|
const stringized = registryUri.toString();
|
|
|
|
if (this.#knownUris.has(stringized)) {
|
|
|
|
return this.#database.getRegistryByUri(stringized);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
getRegistryByName(name: string) : Registry | undefined {
|
|
|
|
const asUri = this.#nameToUri.get(name);
|
|
|
|
if (asUri) {
|
|
|
|
return this.#database.getRegistryByUri(asUri);
|
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
return undefined;
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
// Adds `registry` to this context with name `name`. If `name` is already set to a different URI, throws.
|
|
|
|
add(registryUri: Uri, name: string) {
|
|
|
|
const stringized = registryUri.toString();
|
|
|
|
if (!this.#database.has(stringized)) {
|
|
|
|
throw new Error('Attempted to add unloaded registry to a RegistryContext');
|
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
const oldLocation = this.#nameToUri.get(name);
|
|
|
|
if (oldLocation && oldLocation !== stringized) {
|
|
|
|
throw new Error(i`Tried to add ${stringized} as ${name}, but ${name} is already ${oldLocation}.`);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.#knownUris.add(stringized);
|
|
|
|
this.addMapping(name, stringized);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
async search(criteria?: SearchCriteria): Promise<Array<[string, Array<Artifact>]>> {
|
|
|
|
const idOrShortName = criteria?.idOrShortName || '';
|
|
|
|
const [source, name] = parseArtifactDependency(idOrShortName);
|
|
|
|
if (source === undefined) {
|
|
|
|
// search them all
|
|
|
|
const results : Array<[string, Array<Artifact>]> = [];
|
|
|
|
for (const location of this.#knownUris) {
|
|
|
|
const registry = this.#database.getRegistryByUri(location);
|
|
|
|
if (registry === undefined) {
|
|
|
|
throw new Error('RegistryContext tried to search an unloaded registry.');
|
|
|
|
}
|
|
|
|
|
|
|
|
const displayName = this.getRegistryDisplayName(registry.location);
|
|
|
|
for (const [artifactId, artifacts] of await registry.search(criteria)) {
|
|
|
|
results.push([artifactIdentity(displayName, artifactId, artifacts[0].shortName), artifacts]);
|
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
return results;
|
|
|
|
} else {
|
|
|
|
const registry = this.getRegistryByName(source);
|
|
|
|
if (registry) {
|
|
|
|
return (await registry.search({ ...criteria, idOrShortName: name }))
|
|
|
|
.map((artifactRecord) => [artifactIdentity(source, artifactRecord[0], artifactRecord[1][0].shortName), artifactRecord[1]]);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
|
|
|
|
throw new Error(i`Unknown registry ${source} (in ${idOrShortName}). The following are known: ${Array.from(this.#nameToUri.keys()).join(', ')}`);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
// Combines resolvers together. Any registries that match exactly will take their names from `otherResolver`. Any
|
|
|
|
// registries whose names match but which resolve to different URIs will have the name from `otherResolver`, and the
|
|
|
|
// other registry will become known but nameless.
|
|
|
|
with(otherResolver: RegistryResolver) : RegistryResolver {
|
|
|
|
if (this.#database !== otherResolver.#database) {
|
|
|
|
throw new Error('Tried to combine registry resolvers with different databases.');
|
|
|
|
}
|
|
|
|
|
|
|
|
const result = new RegistryResolver(otherResolver);
|
|
|
|
for (const uri of this.#knownUris) {
|
|
|
|
result.#knownUris.add(uri);
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
|
|
|
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
for (const [name, location] of this.#nameToUri) {
|
|
|
|
if (!result.#nameToUri.has(name) && !result.#uriToName.has(location)) {
|
|
|
|
result.addMapping(name, location);
|
|
|
|
}
|
2022-03-23 03:07:57 +03:00
|
|
|
}
|
The great artifacts multi registries overhaul. (#690)
* The great artifacts multi registries overhaul.
User facing intentional behavior changes:
* The --registry switch has been removed. There was basically nothing we could do with a registry for which we had no name.
* Commands which speak registries / IDs now combine the set of names of registries from the global set and the local project set.
* Console output now always displays registries with the following rules:
1. If the registry URI is in the project, the name from the project is used.
2. Otherwise, if the registry URI is is not in the project, and the name of the registry in the global configuration does not conflict with the project, the global configuration's name is used.
3. Otherwise, the URI enclosed in []s is used. This is a signal to the user that they will need to take some form of manual action.
* The command x-regenerate now requires a local file path.
* Several places that used to break when handed relative paths, like x-regenerate, now tolerate this situation correctly.
* If an artifact declares a dependency with explicit registry, and that registry's name is not declared in that artifact, resolution fails. (We no longer will try to find that name in the project / global configuration)
* Commands that need activation options like `add`, and `remove`, no longer try to activate the project.
* Artifacts are now installed and otherwise enumerated in topological sorted order. This is the other half of https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1510278
* There is no longer a built in registry named 'default'.
* Except for index.yaml, a few remaining yaml hangers-on have been replaced with JSON. This may invalidate installed artifacts in the wild. This is necessary for the medium-term goal of deleting the YAML implementation from the product entirely.
* index.yaml no longer begins with 'THIS_IS_NOT_A_MANIFEST_ITS_AN_INDEX_STRING'
Bug fixes:
* The console output no longer gets confused and displays [URL]'d registry names (except as denoted by case (3) above). This was https://devdiv.visualstudio.com/DevDiv/_boards/board/t/Vcpkg%20Package%20Manager/Stories/?workitem=1494994
2022-09-13 00:07:46 +03:00
|
|
|
|
2022-03-23 03:07:57 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|