Skip to content

Commit

Permalink
fix: function docs and pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vadson71 committed Jan 5, 2024
1 parent d615382 commit 4dadf27
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -68,6 +69,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -87,6 +89,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -106,6 +109,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -125,6 +129,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -144,6 +149,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -163,6 +169,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand All @@ -182,6 +189,7 @@
"args": [
"${fileBasenameNoExtension}",
"--coverage=false",
"--maxWorkers=1",
"--config",
"jest.config.js"
],
Expand Down
38 changes: 30 additions & 8 deletions packages/context/src/ui5-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ async function getVersionInfo(
return versionInfo;
}

/**
* Checks whether version libs cache exists and is consistent.
*
* @param version Requested version
* @param framework The UI5 framework version
* @param modelCachePath Path to model data cache on disk
* @param libs Library module names
* @returns true if cache data exists for all libs
*/
async function isVersionLibsCacheValid(
version: string,
framework: UI5Framework,
Expand All @@ -318,12 +327,22 @@ async function isVersionLibsCacheValid(
return result.every((item) => !!item);
}

/**
* Checks whether the test resources for specific version are available locally or on server.
*
* @param versionInfoJsonFetcher Fetcher function which loads version info json
* @param versionLibsFetcher Fetcher function which loads version libs
* @param modelCachePath Path to model data cache on disk
* @param framework The UI5 framework version
* @param version Requested version
* @returns true if resouces are found
*/
async function isVersionResourcesAvailable(
version: string,
framework: UI5Framework,
modelCachePath: string | undefined,
versionInfoJsonFetcher: Fetcher<Json>,
versionLibsFetcher: Fetcher<Json>
versionLibsFetcher: Fetcher<Json>,
modelCachePath: string | undefined,
framework: UI5Framework,
version: string
): Promise<boolean> {
const libs = await getLibs(
modelCachePath,
Expand Down Expand Up @@ -425,9 +444,11 @@ async function negotiateVersion(
/**
* Tries to negotiate UI5 version.
* Note: This function is exported for testing purposes (using a mock fetcher).
* All Three fetchers are exposed to have comprehensive and easy control over web requests in tests
*
* @param versionJsonFetcher Fetcher function which loads version map json
* @param versionInfoJsonFetcher Fetcher function which loads version info json
* @param versionLibsFetcher Fetcher function which loads version libs
* @param modelCachePath Path to model data cache on disk
* @param framework The UI5 framework version
* @param version Requested version
Expand Down Expand Up @@ -633,6 +654,7 @@ function adjustRequestedVersion(
* @param framework Framework type
* @param versions Version map for the current framework
* @param versionInfoJsonFetcher Fetcher function to load remote version data
* @param versionLibsFetcher Fetcher function which loads version libs
* @param modelCachePath Path to model data cache on disk
* @returns Object with resolved version and flag whether the requested version is incorrect and whether the resolved version should be stored in resolution cache
* We don't need to store resolution result in cache if test data available
Expand All @@ -655,11 +677,11 @@ async function resolveRequestedVersion(
if (
!useLatestVersion &&
(await isVersionResourcesAvailable(
requestedVersion,
framework,
modelCachePath,
versionInfoJsonFetcher,
versionLibsFetcher
versionLibsFetcher,
modelCachePath,
framework,
requestedVersion
))
) {
return {
Expand Down

0 comments on commit 4dadf27

Please sign in to comment.