Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sanitize_reuse_lib_lo…
Browse files Browse the repository at this point in the history
…g-message-_input

* origin/main:
  chore: apply latest changesets
  fix: load changes from workspace in Preview after deployment (#2650)
  chore: apply latest changesets
  fix(`odata-service-inquirer`): Apply additional messages to service selection prompt (#2693)
  chore: apply latest changesets
  Cleanup cf tests (#2690)
  chore: apply latest changesets
  fix: Manifest template for services (#2686)
  chore: apply latest changesets
  fix: mock os-name (#2689)
  chore: apply latest changesets
  fix: running test multiple times (#2685)
  chore: apply latest changesets
  fix(app-config-writer): add missing logger parameter for convert preview-config (#2687)
  chore: apply latest changesets
  Replace Keytar with @zowe/secrets-for-zowe-sdk (#2635)
  chore: apply latest changesets
  feat: Enhance extracted FLP prompts to support ADP scenario (#2610)
  chore: apply latest changesets
  feat: Ensuring UI5 2.x compliance for cards-editor-middleware Plugin (#2613)
  • Loading branch information
devinea committed Dec 12, 2024
2 parents bf9ba4a + abdd62f commit dbf6d3a
Show file tree
Hide file tree
Showing 127 changed files with 3,340 additions and 911 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"cwd": "${workspaceFolder}/packages/fiori-freestyle-writer",
"env": {
"UX_DEBUG": "false",
"UX_DEBUG_FULL": "false"
"UX_DEBUG_FULL": "false",
"FIORI_TOOLS_DISABLE_SECURE_STORE": "true"
}
},
{
Expand Down
15 changes: 15 additions & 0 deletions examples/simple-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @sap-ux/generator-simple-fe

## 1.0.96

### Patch Changes

- @sap-ux/fiori-elements-writer@1.3.36
- @sap-ux/fiori-freestyle-writer@1.2.32

## 1.0.95

### Patch Changes

- @sap-ux/system-access@0.5.23
- @sap-ux/fiori-elements-writer@1.3.35
- @sap-ux/fiori-freestyle-writer@1.2.31

## 1.0.94

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/generator-simple-fe",
"version": "1.0.94",
"version": "1.0.96",
"description": "Simple example of a yeoman generator for Fiori elements.",
"license": "Apache-2.0",
"private": true,
Expand Down
18 changes: 18 additions & 0 deletions packages/abap-deploy-config-inquirer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @sap-ux/abap-deploy-config-inquirer

## 1.1.11

### Patch Changes

- Updated dependencies [3ebd767]
- @sap-ux/store@1.0.0
- @sap-ux/system-access@0.5.23
- @sap-ux/ui5-config@0.26.0
- @sap-ux/fiori-generator-shared@0.7.15
- @sap-ux/inquirer-common@0.5.12

## 1.1.10

### Patch Changes

- Updated dependencies [0c64478]
- @sap-ux/inquirer-common@0.5.11

## 1.1.9

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-inquirer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/SAP/open-ux-tools.git",
"directory": "packages/abap-deploy-config-inquirer"
},
"version": "1.1.9",
"version": "1.1.11",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions packages/abap-deploy-config-sub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# @sap-ux/abap-deploy-config-sub-generator

## 0.0.3

### Patch Changes

- @sap-ux/abap-deploy-config-inquirer@1.1.11
- @sap-ux/deploy-config-generator-shared@0.0.6
- @sap-ux/telemetry@0.5.48
- @sap-ux/ui5-config@0.26.0
- @sap-ux/abap-deploy-config-writer@0.0.69
- @sap-ux/fiori-generator-shared@0.7.15

## 0.0.2

### Patch Changes

- @sap-ux/abap-deploy-config-inquirer@1.1.10

## 0.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-sub-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/SAP/open-ux-tools.git",
"directory": "packages/abap-deploy-config-sub-generator"
},
"version": "0.0.1",
"version": "0.0.3",
"license": "Apache-2.0",
"main": "generators/app/index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions packages/abap-deploy-config-writer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sap-ux/abap-deploy-config-writer

## 0.0.69

### Patch Changes

- @sap-ux/system-access@0.5.23
- @sap-ux/ui5-config@0.26.0

## 0.0.68

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abap-deploy-config-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "https://github.com/SAP/open-ux-tools.git",
"directory": "packages/abap-deploy-config-writer"
},
"version": "0.0.68",
"version": "0.0.69",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions packages/adp-tooling/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# @sap-ux/adp-tooling

## 0.12.96

### Patch Changes

- 3ebd767: Replace keytar with @zowe/secrets-for-zowe-sdk
- @sap-ux/system-access@0.5.23
- @sap-ux/ui5-config@0.26.0
- @sap-ux/inquirer-common@0.5.12

## 0.12.95

### Patch Changes

- 0c64478: feat: Enhance extracted FLP prompts to support ADP scenario
- Updated dependencies [0c64478]
- @sap-ux/inquirer-common@0.5.11

## 0.12.94

### Patch Changes
Expand Down
7 changes: 4 additions & 3 deletions packages/adp-tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bugs": {
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
},
"version": "0.12.94",
"version": "0.12.96",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand All @@ -20,8 +20,8 @@
"format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"test": "jest --ci --forceExit --detectOpenHandles --colors --testPathPattern=test/unit",
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
"test": "jest FIORI_TOOLS_DISABLE_SECURE_STORE=true --ci --forceExit --detectOpenHandles --colors --testPathPattern=test/unit",
"test-u": "jest FIORI_TOOLS_DISABLE_SECURE_STORE=true --ci --forceExit --detectOpenHandles --colors -u",
"link": "pnpm link --global",
"unlink": "pnpm unlink --global"
},
Expand All @@ -43,6 +43,7 @@
"@sap-ux/project-input-validator": "workspace:*",
"@sap-ux/system-access": "workspace:*",
"@sap-ux/ui5-config": "workspace:*",
"@sap-ux/i18n": "workspace:*",
"adm-zip": "0.5.10",
"ejs": "3.1.10",
"i18next": "23.11.2",
Expand Down
82 changes: 34 additions & 48 deletions packages/adp-tooling/src/base/abap/manifest-service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import type { Manifest, ManifestNamespace } from '@sap-ux/project-access';
import type { ToolsLogger } from '@sap-ux/logger';
import type { AdpPreviewConfig, DescriptorVariant } from '../../types';
import ZipFile from 'adm-zip';
import type {
AbapServiceProvider,
Ui5AppInfoContent,
AxiosRequestConfig,
ProviderConfiguration
} from '@sap-ux/axios-extension';
import { isAxiosError } from '@sap-ux/axios-extension';
import { createAbapServiceProvider } from '@sap-ux/system-access';

import type { ToolsLogger } from '@sap-ux/logger';
import type { Manifest, ManifestNamespace } from '@sap-ux/project-access';
import { isAxiosError, type AbapServiceProvider, type Ui5AppInfoContent } from '@sap-ux/axios-extension';

import { getWebappFiles } from '../helper';
import type { DescriptorVariant } from '../../types';

type DataSources = Record<string, ManifestNamespace.DataSource>;

/**
* Retrieves the inbound navigation configurations from the project's manifest.
*
* @param {Manifest} manifest - The manifest file object adhering to the SAP JSON schema for web application manifest files.
* @returns {ManifestNamespace.Inbound | undefined} The inbound navigation configurations, or `undefined` if no configurations are present.
*/
export function getInboundsFromManifest(manifest: Manifest): ManifestNamespace.Inbound | undefined {
return manifest?.['sap.app']?.crossNavigation?.inbounds;
}

/**
* Extracts the registration ID from the manifest file.
*
* @param {Manifest} manifest - The manifest file object adhering to the SAP JSON schema for web application manifest files.
* @returns {string | undefined} The first registration ID if available, otherwise `undefined`.
*/
export function getRegistrationIdFromManifest(manifest: Manifest): string | undefined {
return manifest?.['sap.fiori']?.registrationIds?.[0];
}

/**
* Service class for handling operations related to the manifest of a UI5 application.
* The class supports operations for both base and merged manifests.
Expand All @@ -32,69 +47,40 @@ export class ManifestService {
*/
private constructor(private readonly provider: AbapServiceProvider, private readonly logger: ToolsLogger) {}

/**
* Initializes the ManifestService with the given ADP configuration and logger.
*
* @param adpConfig - The ADP preview configuration.
* @param logger - The logger instance.
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
* @returns A promise that resolves to an instance of ManifestService.
*/
private static async init(
adpConfig: AdpPreviewConfig,
logger: ToolsLogger,
requestOptions?: AxiosRequestConfig & Partial<ProviderConfiguration>
): Promise<ManifestService> {
const provider = await createAbapServiceProvider(
adpConfig.target,
{
...requestOptions,
ignoreCertErrors: adpConfig.ignoreCertErrors ?? false
},
true,
logger
);
return new ManifestService(provider, logger);
}

/**
* Creates an instance of the ManifestService and fetches the base manifest of the application.
*
* @param provider - The ABAP service provider instance.
* @param appId - The application ID.
* @param adpConfig - The ADP preview configuration.
* @param logger - The logger instance.
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
* @returns A promise that resolves to an instance of ManifestService.
*/
public static async initBaseManifest(
provider: AbapServiceProvider,
appId: string,
adpConfig: AdpPreviewConfig,
logger: ToolsLogger,
requestOptions?: AxiosRequestConfig & Partial<ProviderConfiguration>
logger: ToolsLogger
): Promise<ManifestService> {
const manifestService = await this.init(adpConfig, logger, requestOptions);
const manifestService = new ManifestService(provider, logger);
await manifestService.fetchBaseManifest(appId);
return manifestService;
}

/**
* Creates an instance of the ManifestService and fetches the merged manifest of the application.
*
* @param provider - The ABAP service provider instance.
* @param basePath - The base path of the application.
* @param variant - The descriptor variant.
* @param adpConfig - The ADP preview configuration.
* @param logger - The logger instance.
* @param requestOptions - Optional configuration options for the Axios request, such as headers, timeout, and base URL
* @returns A promise that resolves to an instance of ManifestService.
*/
public static async initMergedManifest(
provider: AbapServiceProvider,
basePath: string,
variant: DescriptorVariant,
adpConfig: AdpPreviewConfig,
logger: ToolsLogger,
requestOptions?: AxiosRequestConfig & Partial<ProviderConfiguration>
logger: ToolsLogger
): Promise<ManifestService> {
const manifestService = await this.init(adpConfig, logger, requestOptions);
const manifestService = new ManifestService(provider, logger);
await manifestService.fetchMergedManifest(basePath, variant.id);
await manifestService.fetchAppInfo(variant.reference);
return manifestService;
Expand Down
36 changes: 36 additions & 0 deletions packages/adp-tooling/src/base/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { Editor } from 'mem-fs-editor';
import { readdirSync, readFileSync } from 'fs';
import { join, isAbsolute, relative } from 'path';

import { UI5Config } from '@sap-ux/ui5-config';

import type { DescriptorVariant, AdpPreviewConfig } from '../types';

/**
Expand All @@ -13,6 +16,39 @@ export function getVariant(basePath: string): DescriptorVariant {
return JSON.parse(readFileSync(join(basePath, 'webapp', 'manifest.appdescr_variant'), 'utf-8'));
}

/**
* Writes the updated variant content to the manifest.appdescr_variant file.
*
* @param {string} basePath - The base path of the project.
* @param {DescriptorVariant} variant - The descriptor variant object.
* @param {Editor} fs - The mem-fs editor instance.
*/
export function updateVariant(basePath: string, variant: DescriptorVariant, fs: Editor) {
fs.writeJSON(join(basePath, 'webapp', 'manifest.appdescr_variant'), variant);
}

/**
* Checks if FLP configuration changes exist in the manifest.appdescr_variant.
*
* This function determines whether there are changes of type `appdescr_app_changeInbound`
* or `appdescr_app_addNewInbound` present in the content of the descriptor variant.
*
* @param {string} basePath - The base path of the project where the manifest.appdescr_variant is located.
* @returns {boolean} Returns `true` if FLP configuration changes exist, otherwise `false`.
* @throws {Error} Throws an error if the variant could not be retrieved.
*/
export function flpConfigurationExists(basePath: string): boolean {
try {
const variant = getVariant(basePath);
return variant.content?.some(
({ changeType }) =>
changeType === 'appdescr_app_changeInbound' || changeType === 'appdescr_app_addNewInbound'
);
} catch (error) {
throw new Error(`Failed to check if FLP configuration exists: ${(error as Error).message}`);
}
}

/**
* Returns the adaptation project configuration, throws an error if not found.
*
Expand Down
Loading

0 comments on commit dbf6d3a

Please sign in to comment.