Skip to content
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

feat: Switch Adaptation Project's generator/wizard to use Open Source writers #1775

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d207584
feat: enhance writer for ADP Project to be able to create proper ADP …
IvoSG Mar 24, 2024
bb4a0a0
feat: enhance s4hana project generation
IvoSG Mar 25, 2024
363a702
feat: enhance cf project generation
IvoSG Apr 2, 2024
2cffde0
Merge branch 'main' of https://github.com/SAP/open-ux-tools into feat…
IvoSG Apr 2, 2024
774f0ac
fix/lint errors and tests
IvoSG Apr 2, 2024
a9ae35a
fix: unit tests and code corrections
IvoSG Apr 3, 2024
ef58dd5
Linting auto fix commit
github-actions[bot] Apr 3, 2024
9aa7edc
chore: add changeset
IvoSG Apr 3, 2024
0d0bef9
Merge branch 'feat/1611/writersForAdpProjects' of https://github.com/…
IvoSG Apr 3, 2024
464b534
fix: sonar security issue
IvoSG Apr 3, 2024
5ad6495
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Apr 3, 2024
82b0238
chore: split the project template files for the different environments
IvoSG Apr 16, 2024
32a3214
chore: use btp-utils to check the running environment
IvoSG Apr 16, 2024
5956a34
chore: split the writers logic
IvoSG Apr 16, 2024
8a25655
chore: add writer factory to instantiate class for different environm…
IvoSG Apr 16, 2024
5d6d4cb
fix: remove cf writer logic, move project utils and fix ui5-deploy.ya…
IvoSG Apr 24, 2024
004b5cb
chore: use one project template for onprem and s4 project types
IvoSG Apr 24, 2024
f28ca6e
fix: ui5-deploy.yaml writer and add appredload middleware
IvoSG Apr 25, 2024
43ca69a
chore: revert all writers factory logic, revert project template stru…
IvoSG Apr 26, 2024
4af85b2
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Apr 26, 2024
8ac89f4
chore: revert autoupdated import type
IvoSG Apr 26, 2024
09d5cf4
fix: add whitespace
IvoSG Apr 26, 2024
d42387b
fix: merge issue
IvoSG Apr 26, 2024
0e31e07
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Apr 30, 2024
2507b01
chore: change types and remove unit tests for cf
IvoSG Apr 30, 2024
cb495b2
fix: default url if not provided
IvoSG Apr 30, 2024
0ca6004
fix: remove .env file, write only changes in apdescr content, use fra…
IvoSG May 16, 2024
3dba791
fix: typo
IvoSG May 16, 2024
6c21e2f
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 16, 2024
0516fc4
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 17, 2024
35a6347
fix: migrator ui5 yaml writers
IvoSG May 17, 2024
a2c2b71
chore: remove credentials from ui5.yaml config, move inbound change l…
IvoSG May 22, 2024
1da5255
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 22, 2024
3bed8d2
Merge branch 'main' of https://github.com/SAP/open-ux-tools into feat…
IvoSG May 23, 2024
edb43db
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 23, 2024
b970461
Merge branch 'main' into feat/1611/writersForAdpProjects
tobiasqueck May 24, 2024
31153cf
Merge branch 'main' into feat/1611/writersForAdpProjects
tobiasqueck May 27, 2024
196fc44
chore: resolve code review comments
IvoSG May 29, 2024
0e12110
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 29, 2024
4158c84
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 29, 2024
113e2af
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG May 30, 2024
513b0f7
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 3, 2024
328b15d
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 3, 2024
c05b0dd
fix: add JSDoc to the types, remove unused tests and revert fs, cover…
IvoSG Jun 4, 2024
8f5b365
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 4, 2024
bce2d5c
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 4, 2024
db1a539
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 4, 2024
a6ac36a
chore: move new inbound navigation properties to an internal type
IvoSG Jun 5, 2024
78f7a82
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 5, 2024
c190b64
fix: adapt existed tests
IvoSG Jun 5, 2024
a933d59
test: adding missing tests, refactoring tests
IvoSG Jun 6, 2024
5e74a2a
fix: resolve sonar issue
IvoSG Jun 6, 2024
be4d7e1
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 6, 2024
515d984
Merge branch 'main' into feat/1611/writersForAdpProjects
IvoSG Jun 6, 2024
114591d
Merge branch 'main' into feat/1611/writersForAdpProjects
GDamyanov Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-panthers-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/adp-tooling': minor
---

Adds writer functionality for generation of adaptation projects
127 changes: 115 additions & 12 deletions packages/adp-tooling/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { UI5FlexLayer } from '@sap-ux/project-access';
import type { DestinationAbapTarget, UrlAbapTarget } from '@sap-ux/system-access';
import type { Adp } from '@sap-ux/ui5-config';
import type { Editor } from 'mem-fs-editor';
import type { Adp, BspApp } from '@sap-ux/ui5-config';
import type { OperationsType } from '@sap-ux/axios-extension';
import type { Editor } from 'mem-fs-editor';

export interface DescriptorVariant {
layer: UI5FlexLayer;
Expand All @@ -26,13 +26,30 @@ export interface AdpPreviewConfig {
ignoreCertErrors?: boolean;
}

export interface OnpremApp {
/** Application variant id. */
id: string;
/** Reference associated with the ID of the base application. */
reference: string;
layer?: UI5FlexLayer;
title?: string;
/** Optional: Application variant change content. */
content?: Content[];
}

export interface CloudApp extends OnpremApp {
/** bspName associated with the ABAP Cloud repository name of the base application. */
bspName: string;
/** Cloud app active languages. */
languages: Language[];
}

export type App = OnpremApp | CloudApp;

export type DeployConfig = Adp | BspApp;

export interface AdpWriterConfig {
app: {
id: string;
reference: string;
layer?: UI5FlexLayer;
title?: string;
};
app: App;
target: AbapTarget;
ui5?: {
tobiasqueck marked this conversation as resolved.
Show resolved Hide resolved
minVersion?: string;
Expand All @@ -43,11 +60,12 @@ export interface AdpWriterConfig {
name?: string;
description?: string;
};
customConfig?: AdpCustomConfig;
flp?: FlpConfig;
customConfig?: CustomConfig;
/**
* Optional: configuration for deployment to ABAP
*/
deploy?: Adp;
deploy?: DeployConfig;
options?: {
/**
* Optional: if set to true then the generated project will be recognized by the SAP Fiori tools
Expand All @@ -56,6 +74,42 @@ export interface AdpWriterConfig {
};
}

export interface ChangeInboundNavigation {
/** Identifier for the inbound navigation. */
inboundId: string;
tobiasqueck marked this conversation as resolved.
Show resolved Hide resolved
/** Title associated with the inbound navigation. */
title?: string;
/** Subtitle associated with the inbound navigation. */
subTitle?: string;
}

export interface NewInboundNavigation {
/** Represent business entities that reflect a specific scenario. */
semanticObject: string;
/** Operations which can be performed on a semantic object. */
action: string;
//** Defined instance of the semantic object (e.g. by specifying the employee ID). */
additionalParameters?: object;
/** Title associated with the inbound navigation. */
title: string;
/** Optional: Subtitle associated with the inbound navigation. */
subTitle?: string;
}

export interface InternalInboundNavigation extends NewInboundNavigation {
/** Identifier for the inbound navigation. */
inboundId: string;
/** Flag indicating if the new inbound navigation should be added. */
addInboundId: boolean;
}

export type FlpConfig = ChangeInboundNavigation | NewInboundNavigation;

export interface Language {
sap: string;
i18n: string;
}

export interface ManifestAppdescr {
fileName: string;
layer: string;
Expand Down Expand Up @@ -175,6 +229,7 @@ export type IWriterData<T extends ChangeType> = IWriter<GeneratorData<T>>;
*
* @template T - The specific type of data the writer will handle, determined by the associated ChangeType.
*/

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this extra empty line as it detaches the jsdoc from the interface.

export interface IWriter<T> {
/**
* Writes the provided data to the project.
Expand Down Expand Up @@ -345,9 +400,57 @@ export interface AdpProjectData {
id: string;
}

export interface AdpCustomConfig {
export interface CustomConfig {
adp: {
safeMode: boolean;
nikmace marked this conversation as resolved.
Show resolved Hide resolved
environment: OperationsType;
};
}
}

export interface InboundChangeContentAddInboundId {
inbound: {
[inboundId: string]: AddInboundModel;
};
}
export interface AddInboundModel {
/** Represent business entities that reflect a specific scenario. */
semanticObject: string;
/** Operations which can be performed on a semantic object. */
action: string;
/** Title associated with the inbound navigation data. */
title: string;
/** Optional: Subtitle associated with the inbound navigation data. */
subTitle?: string;
signature: AddInboundSignitureModel;
}
export interface AddInboundSignitureModel {
parameters: InboundParameters;
//** Defined instance of the semantic object (e.g. by specifying the employee ID). */
additionalParameters: string;
}
export interface InboundParameters {
'sap-appvar-id'?: object;
'sap-priority'?: object;
}

export interface InboundChange {
inbound: {
[key: string]: {
/** Represent business entities that reflect a specific scenario. */
semanticObject: string;
/** Operations which can be performed on a semantic object. */
action: string;
/** Icon associated with the inbound navigation data. */
icon: string;
/** Title associated with the inbound navigation data. */
title: string;
/** Subtitle associated with the inbound navigation data. */
subTitle: string;
signature: {
parameters: object | string;
//** Defined instance of the semantic object (e.g. by specifying the employee ID). */
additionalParameters: 'allowed';
};
};
};
}
23 changes: 18 additions & 5 deletions packages/adp-tooling/src/writer/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { join } from 'path';
import { create as createStorage } from 'mem-fs';
import type { Editor } from 'mem-fs-editor';
import { create } from 'mem-fs-editor';
import type { AdpWriterConfig } from '../types';
import { create, type Editor } from 'mem-fs-editor';
import type { AdpWriterConfig, InternalInboundNavigation } from '../types';
import { enhanceManifestChangeContentWithFlpConfig } from './options';
import { writeTemplateToFolder, writeUI5Yaml, writeUI5DeployYaml } from './project-utils';

const tmplPath = join(__dirname, '../../templates/project');
Expand All @@ -14,12 +14,13 @@ const tmplPath = join(__dirname, '../../templates/project');
* @returns enhanced configuration with default values
*/
function setDefaults(config: AdpWriterConfig): AdpWriterConfig {
const configWithDefaults: AdpWriterConfig = {
const configWithDefaults: AdpWriterConfig & { flp?: InternalInboundNavigation } = {
app: { ...config.app },
target: { ...config.target },
ui5: { ...config.ui5 },
deploy: config.deploy ? { ...config.deploy } : undefined,
options: { ...config.options },
flp: config.flp ? ({ ...config.flp } as InternalInboundNavigation) : undefined,
customConfig: config.customConfig ? { ...config.customConfig } : undefined
};
configWithDefaults.app.title ??= `Adaptation of ${config.app.reference}`;
Expand All @@ -29,6 +30,11 @@ function setDefaults(config: AdpWriterConfig): AdpWriterConfig {
configWithDefaults.package.name ??= config.app.id.toLowerCase().replace(/\./g, '-');
configWithDefaults.package.description ??= configWithDefaults.app.title;

if (configWithDefaults.flp && !configWithDefaults.flp.inboundId) {
configWithDefaults.flp.addInboundId = true;
configWithDefaults.flp.inboundId = `${configWithDefaults.app.id}.InboundID`;
}

return configWithDefaults;
}

Expand All @@ -44,8 +50,16 @@ export async function generate(basePath: string, config: AdpWriterConfig, fs?: E
if (!fs) {
fs = create(createStorage());
}

const fullConfig = setDefaults(config);

if (fullConfig.customConfig?.adp.environment === 'C' && fullConfig.flp) {
enhanceManifestChangeContentWithFlpConfig(
fullConfig.flp as InternalInboundNavigation,
fullConfig.app.id,
fullConfig.app.content
);
}
writeTemplateToFolder(join(tmplPath, '**/*.*'), join(basePath), fullConfig, fs);
await writeUI5DeployYaml(basePath, fullConfig, fs);
await writeUI5Yaml(basePath, fullConfig, fs);
Expand All @@ -61,7 +75,6 @@ export async function generate(basePath: string, config: AdpWriterConfig, fs?: E
* @param fs - the memfs editor instance
* @returns the updated memfs editor instance
*/

export async function migrate(basePath: string, config: AdpWriterConfig, fs?: Editor): Promise<Editor> {
if (!fs) {
fs = create(createStorage());
Expand Down