Skip to content

Commit

Permalink
Merge branch 'feat/2727/adp-flp-configuration-generator' of https://g…
Browse files Browse the repository at this point in the history
…ithub.com/SAP/open-ux-tools into feat/2727/adp-flp-configuration-generator
  • Loading branch information
mmilko01 committed Jan 8, 2025
2 parents ef44a9c + d5a8803 commit 1d6b41d
Show file tree
Hide file tree
Showing 230 changed files with 9,859 additions and 367 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-students-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/ui5-library-writer': patch
---

add versioning to ui5 lib templates, update deprecated code
11 changes: 11 additions & 0 deletions examples/odata-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @sap-ux/odata-cli

## 0.16.0

### Minor Changes

- 2e3c15e: Proper check for cloud ABAP systems

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0

## 0.15.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/odata-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/odata-cli",
"version": "0.15.16",
"version": "0.16.0",
"description": "Simple example CLI uing the @sap-ux/axios-extension module to fetch metadata and annotations from an SAP system.",
"license": "Apache-2.0",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/odata-cli/src/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export async function testUiServiceGenerator(
TEST_TRANSPORT: string;
}
): Promise<void> {
const s4Cloud = await provider.isS4Cloud();
const s4Cloud = await provider.isAbapCloud();
if (!s4Cloud) {
logger.warn('Not an S/4 Cloud system. UI service generation might not be supported.');
}
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.103

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0
- @sap-ux/system-access@0.5.25

## 1.0.102

### Patch Changes

- @sap-ux/fiori-elements-writer@1.3.42
- @sap-ux/fiori-freestyle-writer@1.2.38

## 1.0.101

### 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.101",
"version": "1.0.103",
"description": "Simple example of a yeoman generator for Fiori elements.",
"license": "Apache-2.0",
"private": true,
Expand Down
16 changes: 16 additions & 0 deletions packages/abap-deploy-config-inquirer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# @sap-ux/abap-deploy-config-inquirer

## 1.1.18

### Patch Changes

- Updated dependencies [dac696a]
- @sap-ux/guided-answers-helper@0.2.0
- @sap-ux/inquirer-common@0.6.2

## 1.1.17

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0
- @sap-ux/system-access@0.5.25

## 1.1.16

### 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.16",
"version": "1.1.18",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
14 changes: 14 additions & 0 deletions packages/abap-deploy-config-sub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @sap-ux/abap-deploy-config-sub-generator

## 0.0.10

### Patch Changes

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

## 0.0.9

### Patch Changes

- @sap-ux/abap-deploy-config-inquirer@1.1.17
- @sap-ux/deploy-config-generator-shared@0.0.9
- @sap-ux/abap-deploy-config-writer@0.0.72

## 0.0.8

### 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.8",
"version": "0.0.10",
"license": "Apache-2.0",
"main": "generators/app/index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions packages/abap-deploy-config-writer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/abap-deploy-config-writer

## 0.0.72

### Patch Changes

- @sap-ux/system-access@0.5.25

## 0.0.71

### 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.71",
"version": "0.0.72",
"license": "Apache-2.0",
"main": "dist/index.js",
"scripts": {
Expand Down
15 changes: 15 additions & 0 deletions packages/adp-tooling/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# @sap-ux/adp-tooling

## 0.12.103

### Patch Changes

- Updated dependencies [dac696a]
- @sap-ux/inquirer-common@0.6.2

## 0.12.102

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0
- @sap-ux/system-access@0.5.25

## 0.12.101

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion 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.101",
"version": "0.12.103",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand Down
13 changes: 13 additions & 0 deletions packages/app-config-writer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @sap-ux/app-config-writer

## 0.5.11

### Patch Changes

- Updated dependencies [2e3c15e]
- @sap-ux/axios-extension@1.18.0

## 0.5.10

### Patch Changes

- d964a24: feat: add option to convert test runners to preview-config command

## 0.5.9

### Patch Changes
Expand Down
6 changes: 4 additions & 2 deletions packages/app-config-writer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/app-config-writer",
"description": "Add or update configuration for SAP Fiori tools application",
"version": "0.5.9",
"version": "0.5.11",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down Expand Up @@ -40,14 +40,16 @@
"i18next": "20.6.1",
"mem-fs": "2.1.0",
"mem-fs-editor": "9.4.0",
"prompts": "2.4.2"
"prompts": "2.4.2",
"semver": "7.6.3"
},
"devDependencies": {
"@sap-ux/preview-middleware": "workspace:*",
"@types/ejs": "3.1.2",
"@types/mem-fs": "1.1.2",
"@types/mem-fs-editor": "7.0.1",
"@types/prompts": "2.4.4",
"@types/semver": "7.5.8",
"axios": "1.7.4",
"nock": "13.4.0"
},
Expand Down
27 changes: 18 additions & 9 deletions packages/app-config-writer/src/preview-config/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { checkPrerequisites, getExplicitApprovalToAdjustFiles } from './prerequisites';
import { create as createStorage } from 'mem-fs';
import { create, type Editor } from 'mem-fs-editor';
import { deleteNoLongerUsedFiles, renameDefaultSandboxes } from './preview-files';
import { updatePreviewMiddlewareConfigs } from './ui5-yaml';
import { deleteNoLongerUsedFiles, renameDefaultSandboxes, renameDefaultTestFiles } from './preview-files';
import { updatePreviewMiddlewareConfigs, updateDefaultTestConfig } from './ui5-yaml';
import { updateVariantsCreationScript } from './package-json';
import { type ToolsLogger } from '@sap-ux/logger';

Expand All @@ -14,14 +14,19 @@ import { type ToolsLogger } from '@sap-ux/logger';
* Corresponding files which are used for the preview are renamed or deleted.
*
* @param basePath - base path to be used for the conversion
* @param logger logger to report info to the user
* @param fs - file system reference
* @param options - options for the conversion
* @param options.convertTests - if set to true, then test suite and test runners fill be included in the conversion
* @param options.logger - logger to report info to the user
* @param options.fs - file system reference
* @returns file system reference
*/
export async function convertToVirtualPreview(basePath: string, logger?: ToolsLogger, fs?: Editor): Promise<Editor> {
if (!fs) {
fs = create(createStorage());
}
export async function convertToVirtualPreview(
basePath: string,
options: { convertTests?: boolean; logger?: ToolsLogger; fs?: Editor }
): Promise<Editor> {
const fs = options.fs ?? create(createStorage());
const logger = options.logger;
const convertTests = options.convertTests ?? false;

if (!(await checkPrerequisites(basePath, fs, logger))) {
throw Error('The prerequisites are not met. For more information, see the log messages above.');
Expand All @@ -32,8 +37,12 @@ export async function convertToVirtualPreview(basePath: string, logger?: ToolsLo
return fs;
}

await updatePreviewMiddlewareConfigs(fs, basePath, logger);
await updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger);
await renameDefaultSandboxes(fs, basePath, logger);
if (convertTests) {
await renameDefaultTestFiles(fs, basePath, logger);
await updateDefaultTestConfig(fs, basePath, logger);
}
await deleteNoLongerUsedFiles(fs, basePath, logger);
await updateVariantsCreationScript(fs, basePath, logger);

Expand Down
20 changes: 13 additions & 7 deletions packages/app-config-writer/src/preview-config/package-json.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { basename, join } from 'path';
import { extractYamlConfigFileName } from './ui5-yaml';
import { extractYamlConfigFileName, isTestPath } from './ui5-yaml';
import { generateVariantsConfig } from '../variants-config';
import type { Editor } from 'mem-fs-editor';
import type { ToolsLogger } from '@sap-ux/logger';
Expand Down Expand Up @@ -49,8 +49,9 @@ export function extractUrlDetails(script: string): {
intent: FlpConfig['intent'] | undefined;
} {
//extract the URL from the 'open' command of the script
let url = / (?:--open|-o|--o) ([^"]?\S*)/.exec(script)?.[1] ?? undefined;
url = url?.startsWith('"') ? url.slice(1) : url;
let url = / (?:--open|-o|--o) (\S*)/.exec(script)?.[1] ?? undefined;
//delete double or single quotes from the URL
url = url?.replace(/['"]/g, '');

//extract the path from the URL
const path = /^[^?#]+\.html/.exec(url ?? '')?.[0] ?? undefined;
Expand Down Expand Up @@ -83,20 +84,25 @@ export function extractUrlDetails(script: string): {
*
* @param scriptName - the name of the script from the package.json file
* @param script - the content of the script from the package.json file
* @param convertTests - indicator if test suite and test runner should be included in the conversion (default: false)
* @returns indicator if the script is valid
*/
export function isValidPreviewScript(scriptName: string, script: string | undefined): boolean {
export function isValidPreviewScript(
scriptName: string,
script: string | undefined,
convertTests: boolean = false
): boolean {
const isValidScriptName =
scriptName != 'start-variants-management' && scriptName != 'start-control-property-editor';

//eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const startsWebServer = !!(script?.includes('ui5 serve') || script?.includes('fiori run'));

const { path } = extractUrlDetails(script ?? '');
const opensTest = path?.includes('qunit.html');
const opensTest = isTestPath(path);
const opensIndexHtml = path === 'index.html';

return isValidScriptName && startsWebServer && !opensTest && !opensIndexHtml;
//tests are only relevant if the conversion of test runners is excluded
return isValidScriptName && startsWebServer && !opensIndexHtml && (convertTests ? true : !opensTest);
}

/**
Expand Down
35 changes: 32 additions & 3 deletions packages/app-config-writer/src/preview-config/prerequisites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ import type { Editor } from 'mem-fs-editor';
import type { Package } from '@sap-ux/project-access';
import type { PromptObject } from 'prompts';
import type { ToolsLogger } from '@sap-ux/logger';
import { satisfies } from 'semver';

/**
* Check if the version of the given package is lower than the minimal version.
*
* @param packageJson - the package.json file content
* @param dependencyName - the name of the (dev)dependency to check
* @param minVersionInfo - the minimal version to check against
* @param mandatory - (default true) if the existence of the dependency is mandatory
* @returns indicator if the version is lower than the minimal version
*/
function isLowerThanMinimalVersion(
packageJson: Package,
dependencyName: string,
minVersionInfo: string,
mandatory: boolean = true
): boolean {
const versionInfo = packageJson?.devDependencies?.[dependencyName] ?? packageJson?.dependencies?.[dependencyName];
if (!versionInfo) {
return mandatory;
}
return !satisfies(minVersionInfo, versionInfo);
}

/**
* Check if the prerequisites for the conversion are met.
Expand Down Expand Up @@ -35,14 +58,20 @@ export async function checkPrerequisites(basePath: string, fs: Editor, logger?:
prerequisitesMet = false;
}

const ui5CliVersion = packageJson?.devDependencies?.['@ui5/cli'] ?? packageJson?.dependencies?.['@ui5/cli'] ?? '0';
if (parseInt(ui5CliVersion.split('.')[0], 10) < 3) {
if (isLowerThanMinimalVersion(packageJson, '@ui5/cli', '3.0.0')) {
logger?.error(
'UI5 CLI version 3.0.0 or higher is required to convert the preview to virtual files. For more information, see https://sap.github.io/ui5-tooling/v3/updates/migrate-v3.'
);
prerequisitesMet = false;
}

if (isLowerThanMinimalVersion(packageJson, '@sap/ux-ui5-tooling', '1.15.4', false)) {
logger?.error(
'UX UI5 Tooling version 1.15.4 or higher is required to convert the preview to virtual files. For more information, see https://www.npmjs.com/package/@sap/ux-ui5-tooling.'
);
prerequisitesMet = false;
}

const ui5MiddlewareMockserverExists =
!!packageJson?.devDependencies?.['@sap-ux/ui5-middleware-fe-mockserver'] ||
!!packageJson?.dependencies?.['@sap-ux/ui5-middleware-fe-mockserver'];
Expand All @@ -69,7 +98,7 @@ export async function getExplicitApprovalToAdjustFiles(): Promise<boolean> {
name: 'approval',
initial: false,
message:
'The converter will rename the HTML files and delete the JS and TS files used for the existing preview functionality and configure virtual files instead. Do you want to proceed with the conversion?'
'The converter will rename the HTML files and delete the JS and TS files used for the existing preview functionality and configure virtual endpoints instead. Do you want to proceed with the conversion?'
};
return Boolean((await prompt([question])).approval);
}
Loading

0 comments on commit 1d6b41d

Please sign in to comment.