Skip to content

fix: enable placeholder for offline mode #744

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/constant/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export {
DEFAULT_UI5_VERSION_BASE,
OPEN_FRAMEWORK,
UI5_FRAMEWORK_CDN_BASE_URL,
UI5_VERSION_S4_PLACEHOLDER
} from "./constant";
2 changes: 2 additions & 0 deletions packages/constant/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ export const UI5_FRAMEWORK_CDN_BASE_URL = {
OpenUI5: "https://sdk.openui5.org/",
SAPUI5: "https://ui5.sap.com/",
};

export const UI5_VERSION_S4_PLACEHOLDER = "${sap.ui5.dist.version}";
3 changes: 2 additions & 1 deletion packages/context/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
} from "./manifest";
import { finAdpdManifestPath } from "./adp-manifest";
import { getServices } from "./services";
import { Context, UI5_VERSION_S4_PLACEHOLDER } from "./types";
import { Context } from "./types";
import { UI5_VERSION_S4_PLACEHOLDER } from "@ui5-language-assistant/constant";
import { getSemanticModel } from "./ui5-model";
import { getYamlDetails } from "./ui5-yaml";
import { getViewFiles } from "./utils/view-files";
Expand Down
2 changes: 0 additions & 2 deletions packages/context/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
import type { XMLDocument } from "@xml-tools/ast";
import { Location } from "vscode-languageserver";

export const UI5_VERSION_S4_PLACEHOLDER = "${sap.ui5.dist.version}";

export const UI5_PROJECT_TYPE = "UI5";
export const CAP_PROJECT_TYPE = "CAP";
export enum DirName {
Expand Down
5 changes: 3 additions & 2 deletions packages/context/src/ui5-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
Json,
TypeNameFix,
} from "@ui5-language-assistant/semantic-model";
import { Fetcher, UI5_VERSION_S4_PLACEHOLDER } from "./types";
import { Fetcher } from "./types";
import { UI5_VERSION_S4_PLACEHOLDER } from "@ui5-language-assistant/constant";
import {
fetch,
getLocalUrl,
Expand Down Expand Up @@ -466,7 +467,7 @@ export async function negotiateVersionWithFetcher(
const isOffline = await isOfflineMode(version);
if (isOffline) {
return {
version: version as string,
version: version === UI5_VERSION_S4_PLACEHOLDER ? 'latest': version as string,
isFallback,
isIncorrectVersion,
};
Expand Down
3 changes: 2 additions & 1 deletion packages/context/test/unit/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import * as viewFiles from "../../src/utils/view-files";
import * as controlIds from "../../src/utils/control-ids";
import { UI5SemanticModel } from "@ui5-language-assistant/semantic-model-types";
import { getContext, isContext } from "../../src/api";
import { UI5_VERSION_S4_PLACEHOLDER, type Context } from "../../src/types";
import { type Context } from "../../src/types";
import { UI5_VERSION_S4_PLACEHOLDER } from "@ui5-language-assistant/constant";
import * as projectAccess from "@sap-ux/project-access";
import { OPEN_FRAMEWORK } from "@ui5-language-assistant/constant";

Expand Down
2 changes: 1 addition & 1 deletion packages/context/test/unit/ui5-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
DEFAULT_UI5_VERSION,
OPEN_FRAMEWORK,
DEFAULT_UI5_FRAMEWORK,
UI5_VERSION_S4_PLACEHOLDER
} from "@ui5-language-assistant/constant";
import { expectExists } from "@ui5-language-assistant/test-utils";
import {
Expand All @@ -45,7 +46,6 @@ import * as logicUtils from "@ui5-language-assistant/logic-utils";
import semverMinSatisfying from "semver/ranges/min-satisfying";
import { Response } from "node-fetch";
import { UI5Framework } from "@ui5-language-assistant/semantic-model-types";
import { UI5_VERSION_S4_PLACEHOLDER } from "../../src/types";
const GET_MODEL_TIMEOUT = 30000;
const NO_CACHE_FOLDER = undefined;
const { getVersionsMap } = logicUtils;
Expand Down
4 changes: 4 additions & 0 deletions packages/logic-utils/src/utils/fetch-helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getConfigurationSettings } from "@ui5-language-assistant/settings";
import { Response } from "node-fetch";
import { fetch } from "./fetch";
import { UI5_VERSION_S4_PLACEHOLDER } from "@ui5-language-assistant/constant";

export const getLocalUrl = (
version?: string,
Expand All @@ -11,6 +12,9 @@ export const getLocalUrl = (
let localUrl = webServer.endsWith("/") ? webServer : `${webServer}/`;

if (version) {
if (version === UI5_VERSION_S4_PLACEHOLDER) {
version = "latest";
}
localUrl += `${version}/`;
}
return localUrl;
Expand Down
Loading