-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix(app-config-writer): wrong prerequisites check in convert preview-config #2922
base: main
Are you sure you want to change the base?
fix(app-config-writer): wrong prerequisites check in convert preview-config #2922
Conversation
🦋 Changeset detectedLatest commit: f63da1f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
The new sonar issue seems to be a false positive because casting to |
…eview-prerequisites' into fix/app-config-writer/convert-preview-prerequisites
|
@@ -35,6 +45,26 @@ function isLowerThanMinimalVersion( | |||
return !satisfies(minVersionInfo, versionInfo); | |||
} | |||
|
|||
/** |
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.
Hi @heimwege, there is already a check for cds plugin in module @sap-ux/cap-config-writer
checkCdsUi5PluginEnabled()
, see:
open-ux-tools/packages/cap-config-writer/src/cap-config/index.ts
Lines 92 to 122 in 280c822
export async function checkCdsUi5PluginEnabled( | |
basePath: string, | |
fs?: Editor, | |
moreInfo?: boolean, | |
cdsVersionInfo?: CdsVersionInfo | |
): Promise<boolean | CdsUi5PluginInfo> { | |
if (!fs) { | |
fs = create(createStorage()); | |
} | |
const packageJsonPath = join(basePath, 'package.json'); | |
if (!fs.exists(packageJsonPath)) { | |
return false; | |
} | |
const packageJson = fs.readJSON(packageJsonPath) as Package; | |
const { workspaceEnabled } = await getWorkspaceInfo(basePath, packageJson); | |
const cdsInfo: CdsUi5PluginInfo = { | |
// Below line checks if 'cdsVersionInfo' is available and contains version information. | |
// If it does, it uses that version information to determine if it satisfies the minimum CDS version required. | |
// If 'cdsVersionInfo' is not available or does not contain version information,it falls back to check the version specified in the package.json file. | |
hasMinCdsVersion: cdsVersionInfo?.version | |
? satisfies(cdsVersionInfo?.version, `>=${minCdsVersion}`) | |
: satisfiesMinCdsVersion(packageJson), | |
isWorkspaceEnabled: workspaceEnabled, | |
hasCdsUi5Plugin: hasCdsPluginUi5(packageJson), | |
isCdsUi5PluginEnabled: false | |
}; | |
cdsInfo.isCdsUi5PluginEnabled = cdsInfo.hasMinCdsVersion && cdsInfo.isWorkspaceEnabled && cdsInfo.hasCdsUi5Plugin; | |
return moreInfo ? cdsInfo : cdsInfo.isCdsUi5PluginEnabled; | |
} | |
export { minCdsVersion }; |
I don't think it is a good idea to have a dependency from @sap-ux/app-config-writer
to @sap-ux/cap-config-writer
, my proposal would be to move the function to @sap-ux/project-access
and call it from there in all places.
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.
@Klaus-Keller done in 104f694 ff. Please check carefully as it was a lot of methods and tests to be adjusted
…s and use in app-config-writer
@@ -1,4 +1,4 @@ | |||
export { checkCdsUi5PluginEnabled, enableCdsUi5Plugin, satisfiesMinCdsVersion } from './cap-config'; |
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.
@heimwege, I'm wondering whether we should keep the export checkCdsUi5PluginEnabled
for backward compatibility reasons. We would then import and re-export the function. I know of other modules that use the function, search in tools suite for checkCdsUi5PluginEnabled
. From a semver perspective this would be breaking changes and require a major version increase, but as we are on a 0.x.y
version here we could do such incompatible changes. We just need to be careful and adjust all consumers, not only in this repo.
Let me know what you think.
@@ -0,0 +1,5 @@ | |||
--- |
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.
@sap-ux/project-access
and @sap-ux/ui5-application-inquirer
are missing in changeset
@@ -47,7 +47,13 @@ export { | |||
readUi5Yaml, | |||
refreshSpecificationDistTags, | |||
toReferenceUri, | |||
updatePackageScript | |||
updatePackageScript, | |||
hasCdsPluginUi5, |
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.
Do we need to export this? Is it not also part of checkCdsUi5PluginEnabled
?
getWorkspaceInfo, | ||
getWorkspacePackages, |
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.
Can we combine getWorkspaceInfo
and getWorkspacePackages
or add them to results to checkCdsUi5PluginEnabled
?
hasCdsPluginUi5, | ||
getWorkspaceInfo, | ||
getWorkspacePackages, | ||
minCdsVersion, |
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.
Perhaps we add this to constants.ts
and change it to Uppercase? Also a more speakable name might help, like MinCdsVersionUi5Plugin
?
getWorkspaceInfo, | ||
getWorkspacePackages, | ||
minCdsVersion, | ||
hasMinCdsVersion, |
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.
Do we need a separate export for this, info is also included in checkCdsUi5PluginEnabled
* @returns true: devDependency to cds-plugin-ui5 exists; false: devDependency to cds-plugin-ui5 does not exist | ||
*/ | ||
export function hasCdsPluginUi5(packageJson: Package): boolean { | ||
return !!packageJson.devDependencies?.['cds-plugin-ui5']; |
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.
We have already
open-ux-tools/packages/project-access/src/project/dependencies.ts
Lines 15 to 16 in 4859d13
export const hasDependency = (packageJson: Package, dependency: string): boolean => | |
!!(packageJson.dependencies?.[dependency] ?? packageJson.devDependencies?.[dependency]); |
which checks for both:
dependencies
and devDependencies
which I think is even better, if someone decides to have cds-plgin-ui5
as dependency we still should enable tooling for it
Co-authored-by: Klaus Keller <[email protected]>
cds-plugin-ui5
is currently being searched inpackage.json
of the app to be converted but must be searched for in CAP rootpackage.json
.This fix currently leads to an exception in project-access checkFilesInSrvFolder in case the CAP srv folder contains sub folders. (fixed in #2923)
Depends on #2926 being merged ✅