-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: main
Are you sure you want to change the base?
Changes from 11 commits
d207584
bb4a0a0
363a702
2cffde0
774f0ac
a9ae35a
ef58dd5
9aa7edc
0d0bef9
464b534
5ad6495
82b0238
32a3214
5956a34
8a25655
5d6d4cb
004b5cb
f28ca6e
43ca69a
4af85b2
8ac89f4
09d5cf4
d42387b
0e31e07
2507b01
cb495b2
0ca6004
3dba791
6c21e2f
0516fc4
35a6347
a2c2b71
1da5255
3bed8d2
edb43db
b970461
31153cf
196fc44
0e12110
4158c84
113e2af
513b0f7
328b15d
c05b0dd
8f5b365
bce2d5c
db1a539
a6ac36a
78f7a82
c190b64
a933d59
5e74a2a
be4d7e1
515d984
114591d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@sap-ux/adp-tooling': minor | ||
'@sap-ux/preview-middleware': patch | ||
--- | ||
|
||
Adds writer functionality for generation of Adaptation Project's | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
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 { Adp, BspApp } from '@sap-ux/ui5-config'; | ||
import type { Editor } from 'mem-fs-editor'; | ||
|
||
export interface DescriptorVariant { | ||
|
@@ -35,23 +35,40 @@ export interface AdpWriterConfig { | |
target: AbapTarget; | ||
ui5?: { | ||
tobiasqueck marked this conversation as resolved.
Show resolved
Hide resolved
|
||
minVersion?: string; | ||
ui5Version?: string; | ||
ui5EndpointUrl?: string; | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
package?: { | ||
name?: string; | ||
description?: string; | ||
}; | ||
flp?: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That object is odd. What is the difference between There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
flpTitle?: string; | ||
flpSubtitle?: string; | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
inboundId?: string; | ||
bspName?: string; | ||
languages?: language[]; | ||
}; | ||
customConfig?: AdpCustomConfig; | ||
/** | ||
* Optional: configuration for deployment to ABAP | ||
*/ | ||
deploy?: Adp; | ||
deploy?: Adp | BspApp; | ||
options?: { | ||
/** | ||
* Optional: if set to true then the generated project will be recognized by the SAP Fiori tools | ||
*/ | ||
fioriTools?: boolean; | ||
isRunningInBAS?: boolean; | ||
isCloudProject?: boolean; | ||
}; | ||
} | ||
|
||
export interface language { | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sap: string; | ||
i18n: string; | ||
} | ||
|
||
export interface ManifestAppdescr { | ||
fileName: string; | ||
layer: string; | ||
|
@@ -347,3 +364,49 @@ export interface AdpProjectData { | |
reference: string; | ||
id: string; | ||
} | ||
|
||
export interface AdpCustomConfig { | ||
adp?: { | ||
safeMode: boolean; | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} | ||
|
||
export interface CfModuleData { | ||
appHostId: string; | ||
appName: string; | ||
appVersion: string; | ||
appId: string; | ||
module: string; | ||
moduleTitle: string; | ||
appVariantId: string; | ||
projectName: string; | ||
i18nGuid: string; | ||
projectPath: string; | ||
addSecurity: string; | ||
addStandaloneApprouter: boolean; | ||
sapCloudService: string; | ||
xsSecurityProjectName: string; | ||
org: string; | ||
space: string; | ||
html5RepoRuntime: string; | ||
} | ||
|
||
export interface CfAdpConfig { | ||
componentname: string; | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
safeMode: boolean; | ||
appvariant: string; | ||
layer: string; | ||
isOVPApp: boolean; | ||
isFioriElement: boolean; | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
environment: string; | ||
ui5Version: string; | ||
cfSpace: string; | ||
cfOrganization: string; | ||
cfApiUrl: string; | ||
} | ||
|
||
export interface CfWriterConfig { | ||
app: CfModuleData; | ||
appdescr: ManifestAppdescr; | ||
adpConfig: CfAdpConfig; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 { CfWriterConfig, ManifestAppdescr } from '../types'; | ||
|
||
/** | ||
* Writes the adp-project template to the mem-fs-editor instance. | ||
* | ||
* @param basePath - the base path | ||
* @param config - the writer configuration | ||
* @param fs - the memfs editor instance | ||
* @returns the updated memfs editor instance | ||
*/ | ||
export async function generateCf(basePath: string, config: CfWriterConfig, fs?: Editor): Promise<Editor> { | ||
if (!fs) { | ||
fs = create(createStorage()); | ||
} | ||
const tmplPath = join(__dirname, '../../templates/projects/cf'); | ||
|
||
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') | ||
}); | ||
IvoSG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// manifest.appdescr_variant | ||
const appdescrTplPath = join(tmplPath, 'manifest.appdescr_variant'); | ||
const appdescrPath = join(basePath, 'webapp/manifest.appdescr_variant'); | ||
const baseAppdescrContent: ManifestAppdescr = JSON.parse(fs.read(appdescrTplPath)); | ||
config.appdescr.content = [...baseAppdescrContent.content, ...config.appdescr.content]; | ||
Object.assign(baseAppdescrContent, config.appdescr); | ||
fs.writeJSON(appdescrPath, baseAppdescrContent); | ||
// .adp/config.json | ||
const adpConfigPath = join(basePath, '.adp/config.json'); | ||
fs.writeJSON(adpConfigPath, config.adpConfig); | ||
// approuter | ||
if (config.app.addStandaloneApprouter) { | ||
fs.copyTpl(join(tmplPath, 'approuter/*.*'), join(basePath, 'approuter'), config.app); | ||
} | ||
// xs-security.json | ||
if (!fs.exists(join(config.app.projectPath, 'xs-security.json'))) { | ||
fs.copyTpl(join(tmplPath, 'xs-security.json'), join(config.app.projectPath, 'xs-security.json'), { | ||
projectName: config.app.xsSecurityProjectName | ||
}); | ||
} | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return fs; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { CustomMiddleware, UI5Config } from '@sap-ux/ui5-config'; | ||
import type { CustomMiddleware, UI5Config, CustomTask, AbapTarget } from '@sap-ux/ui5-config'; | ||
import type { AdpWriterConfig } from '../types'; | ||
|
||
/** | ||
|
@@ -9,7 +9,17 @@ import type { AdpWriterConfig } from '../types'; | |
*/ | ||
export function enhanceUI5Yaml(ui5Config: UI5Config, config: AdpWriterConfig) { | ||
const middlewares = config.options?.fioriTools ? getFioriToolsMiddlwares(config) : getOpenSourceMiddlewares(config); | ||
ui5Config.setConfiguration({ propertiesFileSourceEncoding: 'UTF-8' }); | ||
ui5Config.addCustomMiddleware(middlewares); | ||
|
||
if (config.customConfig?.adp) { | ||
ui5Config.addCustomConfiguration('adp', config.customConfig.adp); | ||
} | ||
if (config.options?.isRunningInBAS && config.options?.isCloudProject && config.ui5?.ui5Version) { | ||
ui5Config.addUI5Framework('SAPUI5', config.ui5.ui5Version, []); | ||
const tasks = getAdpCloudCustomTasks(config); | ||
ui5Config.addCustomTasks(tasks); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -61,8 +71,9 @@ function getFioriToolsMiddlwares(config: AdpWriterConfig): CustomMiddleware<unkn | |
configuration: { | ||
ignoreCertErrors: false, | ||
ui5: { | ||
version: config?.ui5?.minVersion, | ||
path: ['/resources', '/test-resources'], | ||
url: 'https://ui5.sap.com' | ||
url: config?.ui5?.ui5EndpointUrl | ||
}, | ||
backend: [ | ||
{ | ||
|
@@ -120,3 +131,36 @@ function getOpenSourceMiddlewares(config: AdpWriterConfig): CustomMiddleware<obj | |
} | ||
]; | ||
} | ||
|
||
/** | ||
* Get a list of required custom tasks using the Fiori tools. | ||
* | ||
* @param config full project configuration | ||
* @returns list of required tasks. | ||
*/ | ||
function getAdpCloudCustomTasks(config: AdpWriterConfig & { target: AbapTarget }): CustomTask[] { | ||
const user = 'env:ABAP_USERNAME'; | ||
const pass = 'env:ABAP_PASSWORD'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed on the phone, please remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
return [ | ||
{ | ||
name: 'app-variant-bundler-build', | ||
beforeTask: 'escapeNonAsciiCharacters', | ||
configuration: { | ||
type: 'abap', | ||
destination: config.target?.destination, | ||
appName: config?.flp?.bspName, | ||
languages: config?.flp?.languages?.map((language: { sap: string; i18n: string }) => { | ||
return { | ||
sap: language.sap, | ||
i18n: language.i18n | ||
}; | ||
}), | ||
credentials: { | ||
username: user, | ||
password: pass | ||
} | ||
} | ||
} | ||
]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { join } from 'path'; | ||
import { create as createStorage } from 'mem-fs'; | ||
import type { Editor } from 'mem-fs-editor'; | ||
import { create } from 'mem-fs-editor'; | ||
|
||
/** | ||
* Writes the s4hana env file to the mem-fs-editor instance. | ||
* | ||
* @param basePath - the base path | ||
* @param data - personal data intended to be exposed as env variables | ||
* @param fs - the memfs editor instance | ||
* @returns the updated memfs editor instance | ||
*/ | ||
export async function generateEnv(basePath: string, data: string, fs?: Editor): Promise<Editor> { | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!fs) { | ||
fs = create(createStorage()); | ||
} | ||
|
||
fs.write(join(basePath, '.env'), data); | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return fs; | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "<%= package.name %>", | ||
"version": "0.1.0",<% if (locals.options?.isRunningInBAS && locals.options?.isCloudProject) { %> | ||
"main": "index.js",<% } %> | ||
"private": true, | ||
"description": "<%= package.description %>", | ||
"keywords": [ | ||
"ui5", | ||
"sapui5", | ||
"adaptation-project" | ||
],<% if (locals.options?.isRunningInBAS && locals.options?.isCloudProject) { %> | ||
"repository": { | ||
"type": "git", | ||
"build": "ui5.js build --verbose --include-task generateCachebusterInfo" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"ui5": { | ||
"dependencies": ["@sap/ui5-builder-webide-extension", "@ui5/task-adaptation"] | ||
},<% } %> | ||
"devDependencies": { | ||
<%if (locals.options?.fioriTools) {%>"@sap/ux-ui5-tooling": "^1.11.4"<%} else {%>"@sap-ux/backend-proxy-middleware": "^0.7.5", | ||
nikmace marked this conversation as resolved.
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"<%}%>,<% if (locals.options?.isRunningInBAS && locals.options?.isCloudProject) { %> | ||
"@sap/ui5-builder-webide-extension": "1.0.x", | ||
"@sapui5/ts-types": "^1.85.1", | ||
"@types/js-yaml": "^4.0.5", | ||
"@types/semver": "^7.3.13", | ||
"@ui5/task-adaptation": "^1.0.10", | ||
"bestzip": "2.1.4", | ||
"rimraf": "3.0.2",<% } %> | ||
"@ui5/cli": "^3.6.0" | ||
},<% if (locals.options?.isRunningInBAS && locals.options?.isCloudProject) { %> | ||
"dependencies": { | ||
"dotenv": "^16.0.3", | ||
"inquirer": "^8.2.5", | ||
"json-diff": "^1.0.6", | ||
"prompt-sync": "^4.2.0", | ||
"prompts": "^2.4.2", | ||
"xml-js": "^1.6.11" | ||
},<% } %> | ||
"scripts": {<% if (locals.options?.isCloudProject) { %> | ||
"build": "ui5 build --include-task=generateCachebusterInfo && npm run zip", | ||
"prebuild": "npm run clean", | ||
"zip": "cd dist && npx bestzip ../<%= package.name %>.zip *", | ||
"clean": "npx rimraf <%= package.name %>.zip dist", | ||
"build-ui5": "npm explore @ui5/task-adaptation && npm run rollup", | ||
"deploy": "npm run build && fiori deploy --config ui5-deploy.yaml && rimraf archive.zip", | ||
"undeploy": "fiori undeploy --config ui5-deploy.yaml", | ||
"deploy-test": "npm run build && fiori deploy --config ui5-deploy.yaml --testMode true"<% } else { %> | ||
"build": "ui5 build --exclude-task generateFlexChangesBundle generateComponentPreload --clean-dest", | ||
"start": "<%= locals.options?.fioriTools ? 'fiori run' : 'ui5 serve' %> --open /test/flp.html#app-preview", | ||
"start-editor": "<%= locals.options?.fioriTools ? 'fiori run' : 'ui5 serve' %> --open /test/adaptation-editor.html"<%if (locals.deploy) {%>, | ||
"deploy": "ui5 build --config ui5-deploy.yaml --exclude-task <%= locals.options?.fioriTools ? 'deploy-to-abap' : 'abap-deploy-task' %> generateFlexChangesBundle generateComponentPreload --clean-dest && <%= locals.options?.fioriTools ? 'fiori deploy' : 'deploy' %> --config ui5-deploy.yaml", | ||
nikmace marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"undeploy": "<%= locals.options?.fioriTools ? 'fiori undeploy' : 'undeploy' %> --config ui5-deploy.yaml --lrep \"apps/<%= app.reference %>/appVariants/<%= app.id %>/\""<%}%><% } %> | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove preview-middleware and axios-extension from the changeset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done