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 31 commits into
base: main
Choose a base branch
from

Conversation

IvoSG
Copy link
Contributor

@IvoSG IvoSG commented Mar 25, 2024

Feat for #1611.

Adds writer functionality for adaptation projects.

@IvoSG IvoSG requested review from GDamyanov and nikmace March 25, 2024 11:32
Copy link

changeset-bot bot commented Mar 25, 2024

🦋 Changeset detected

Latest commit: 35a6347

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@sap-ux/adp-tooling Minor
@sap-ux/preview-middleware Patch
@sap-ux/axios-extension Patch
@sap-ux/create Patch
@sap-ux/app-config-writer Patch
@sap-ux/backend-proxy-middleware Patch
@sap-ux/deploy-tooling Patch
@sap-ux/environment-check Patch
@sap-ux/system-access Patch
@sap-ux/odata-cli Patch
@sap-ux/generator-simple-fe Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@IvoSG IvoSG added adp-tooling feature New feature or request preview-middleware @sap-ux/preview-middleware labels Apr 3, 2024
@IvoSG IvoSG changed the title Feat/1611/writers for adp projects feat: Switch Adaptation Project's generator/wizard to use Open Source writers Apr 3, 2024
@IvoSG IvoSG marked this pull request as ready for review April 3, 2024 06:22
@IvoSG IvoSG requested a review from a team as a code owner April 3, 2024 06:22
Copy link

sonarcloud bot commented Apr 3, 2024

Copy link
Contributor

@nikmace nikmace left a comment

Choose a reason for hiding this comment

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

Coverage is currently at 88.7% and could be improved a little bit.

packages/adp-tooling/src/types.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/writer/cf.ts Outdated Show resolved Hide resolved
Comment on lines 21 to 27
fs.copyTpl(join(tmplPath, '**/*.*'), join(basePath), config.app, undefined, {
globOptions: { dot: true, ignore: ['**/xs-security.json', '**/approuter/*.*', '**/manifest.appdescr_variant'] },
processDestinationPath: (filePath: string) =>
filePath
.replace(/gitignore.tmpl/g, '.gitignore')
.replace(/i18n\/i18n.properties/g, 'webapp/i18n/i18n.properties')
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This can also be a new method that will handle the copying of the files. See the comment below for the full picture.

packages/adp-tooling/src/writer/s4hana.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/writer/s4hana.ts Outdated Show resolved Hide resolved
packages/adp-tooling/templates/projects/abap/package.json Outdated Show resolved Hide resolved
Comment on lines -77 to +75
\\"@ui5/cli\\": \\"^3.9.1\\"
\\"@ui5/cli\\": \\"^3.6.0\\"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question, why did this version change? It was ^3.9.1 before. ^3.6.0 will install the latest too.

.changeset/famous-panthers-occur.md Outdated Show resolved Hide resolved
packages/adp-tooling/src/types.ts Show resolved Hide resolved
@nikmace nikmace requested a review from testojs April 4, 2024 07:18
packages/adp-tooling/src/types.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/types.ts Outdated Show resolved Hide resolved
packages/adp-tooling/templates/projects/abap/package.json Outdated Show resolved Hide resolved
@IvoSG IvoSG requested a review from a team as a code owner April 16, 2024 05:37
Copy link
Contributor

@nikmace nikmace left a comment

Choose a reason for hiding this comment

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

GitHub actions for some reason are not running and I cannot see the result of those voters. Also, there are some merge conflicts to be resolved.

Some comments from before have not been addressed yet. And could you please write what have you changed in my requested changes comments, so I can resolve those comments.

@@ -14,7 +14,7 @@
"@sap-ux/preview-middleware": "^0.11.1",
"@sap-ux/ui5-proxy-middleware": "^1.3.0",
"@sap-ux/deploy-tooling": "^0.11.7"<%}%>,
"@ui5/cli": "^3.9.1"
"@ui5/cli": "^3.6.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as before, is there any reason for this version "downgrade".

packages/adp-tooling/src/base/project-utils.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/base/project-utils.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/types.ts Outdated Show resolved Hide resolved
export interface AdpCustomConfig {
adp: {
safeMode: boolean;
environment: ProjectType;
Copy link
Contributor

Choose a reason for hiding this comment

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

TBD: the environment is now 'OnPrem' but our change editors still have checks for 'ABAP'

Copy link
Contributor

Choose a reason for hiding this comment

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

@nikmace Why would the change editors need to know about the target environment?

packages/adp-tooling/templates/projects/s4/package.json Outdated Show resolved Hide resolved
Comment on lines 56 to 57
const appdescrTplPath = join(templatePath, 'webapp/manifest.appdescr_variant');
const appdescrPath = join(projectPath, 'webapp/manifest.appdescr_variant');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please use the enum from project access for different folders

packages/adp-tooling/src/base/project-utils.ts Outdated Show resolved Hide resolved
packages/create/src/cli/generate/adaptation-project.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@tobiasqueck tobiasqueck left a comment

Choose a reason for hiding this comment

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

Sorry but that one is far away from being acceptable.

Please remove things like a pom.xml that only make sense for SAP internal projects and also remove all the duplicated files in the templates section.
Projects that are for an ABAP system are almost identical (no matter if on premise, private cloud our public cloud). The only difference is the additional build task and a minor change in the deploy script.
I am not an expert for CF but I am pretty sure that the generated structure is also not aligned with the latest guidance on CF projects.

My recommendation is actually to start from scratch again. Take the existing writer/templates (from main) and compare its results with the three different options. Then enhance the "core" that is the same for all option and add diffs if required for other targets. I'd recommend you have a look at the fiori-elements-writer and how it is designed.

packages/adp-tooling/test/unit/writer/index.test.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/types.ts Outdated Show resolved Hide resolved
packages/adp-tooling/src/types.ts Outdated Show resolved Hide resolved
"@sap-ux/preview-middleware": "^0.11.1",
"@sap-ux/ui5-proxy-middleware": "^1.3.0",
"@sap-ux/deploy-tooling": "^0.11.7"<%}%>,
"@ui5/cli": "^3.9.1"
"@ui5/task-adaptation": "^1.3.0",
"@ui5/cli": "^3.9.2"
},
"scripts": {
"build": "ui5 build --exclude-task generateFlexChangesBundle generateComponentPreload --clean-dest",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add minify to the excluded tasks? Otherwise, .map files will be generated that are rejected by LREP on your ABAP versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
await writeUI5DeployYaml(basePath, fullConfig, fs);
await writeUI5Yaml(basePath, fullConfig, fs);
await writeEnvFile(basePath, fullConfig, fs);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the user know that we are writing user/password to the filesystem? If not, we cannot do that.
Btw, as far as I understand, both user/password are only used for the additional tasks for S/4HANA Cloud Public Edition scenarios, however, such systems won't allow access with user/password, therefore, I'd strongly prefer to remove this user/password/env thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, please remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* @returns list of required tasks.
*/
function getAdpCloudCustomTasks(config: AdpWriterConfig & { target: AbapTarget }): CustomTask[] {
const user = 'env:ABAP_USERNAME';
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in my other comment, this shouldn't be here. In the very worst case that there is a valid scenario for this, use at least FIORI_TOOLS_USER and FIORI_TOOLS_PASSWORD because they are available if any previous Fiori tools task or middleware relied on user/password.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed on the phone, please remove it.

};
package?: {
name?: string;
description?: string;
};
flp?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

That object is odd. bspName and credentials are used to access the original app while title, subtitle and inboundId are only being used in the i18n file. Did you miss adding a change to the appdescr if these properties are present or did I miss it in the code or is there some magic backend functionality that does something on deploy?

What is the difference between bspName and reference in the app section?

Copy link
Contributor Author

@IvoSG IvoSG May 13, 2024

Choose a reason for hiding this comment

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

Currently, the title, subtitle and inbound id are only used in the i18n file because the appdescr information comes already filtered after the prompting.
bspName is the base app repoName and reference is the base app id

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed on the phone, please add the change for the inbound communication to the appdescr template file with the condtion that the flp object is provided

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change for the inbound it's more complex to be in the aprdescr template and because of that it's passed with other changes in the content

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is too complex for ejs, implement it as a plain function and then add it to the list of changes. Most importantly move the logic here because you have a reference to it in your generated i18n.properties file

/**
* Enumerates the types of projects that can be made, each representing a specific kind of project structure.
*/
export const enum ProjectType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Both are S/4 systems here, so please change it to something like Cloud and OnPremise. Even better would be if you reuse the type OperationsType (https://github.com/SAP/open-ux-tools/blob/main/packages/axios-extension/src/abap/types/adt-types.ts#L77) because that is exactly what you will get back from the backend as identify during the prompting phase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@IvoSG IvoSG requested a review from tobiasqueck May 16, 2024 12:15
@@ -7,6 +7,9 @@
"namespace": "apps/<%- app.reference %>/appVariants/<%- app.id %>/",
"version": "0.1.0",
"content": [
<%if(app.content){-%><% for(let change of app.content){-%>
<%- JSON.stringify(change) %><%-","%>
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to align the spacing of your JSON with the rest of the document e.g. JSON.stringify(change, undefined, 4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adp-tooling feature New feature or request preview-middleware @sap-ux/preview-middleware
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants