-
Notifications
You must be signed in to change notification settings - Fork 14
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
[FEATURE] Add Configuration #575
Conversation
lib/config/Configuration.js
Outdated
* @param {string} [filePath="~/.ui5rc"] Path to configuration JSON file | ||
* @param {@ui5/project/config/Configuration} config Configuration to save | ||
*/ | ||
export async function saveConfig(filePath, 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.
It's clear from the RFC that this should be part of the CLI.
Would be removed.
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.
Given the latest discussions and the future integration with Snapshot Consumption, it's worth it that the Config object would be able to read and write into the .ui5rc
file.
The core reasoning behind that is the following scenario:
-
There's an exported static function that reads the file, creates and returns the Configuration object.
-
Writing in
.ui5rc
is a bit more complex: if no.ui5rc
config is provided, then the Resolver checks for env variable, but there's a last resort if none of these is provided (new project setup, for example). In such a case, it's worth checking forsettings.xml
in case the end-user has maven installed on their machine. Then we need to read thesettings.xml
, extract the URL and save it to.ui5rc
We have decided to give it a try. Furthermore, the Configuration object is closed for now and we could eventually revise it
lib/config/Configuration.js
Outdated
} | ||
|
||
|
||
export async function resolveSnapshotEndpointUrl(settingsXML, skipConfirmation) { |
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've discussed this and need to look at it from the perspective of the developers.
We do not expect them to have Maven installed.
With the potential CLI implementation of the configuration settings, it might become redundant.
Developers would eventually need just to execute once a single CLI command like ui5 config set snapshotUrl https://.....
when setting up their environment for the first time.
If we decide that we still need this revolver, its place must be somewhere in the mvn/Installer where it actually is in use.
This would raise another question, though- how to store the resolved value?
lib/config/Configuration.js
Outdated
this.#cwd = cwd ? path.resolve(cwd) : process.cwd(); | ||
this.#sources = !!sources; | ||
this.#version = version; | ||
this.#cacheMode = cacheMode; | ||
this.#ui5HomeDir = ui5HomeDir ? path.resolve(ui5HomeDir) : path.join(os.homedir(), ".ui5"); | ||
|
||
this.#snapshotEndpointUrl = process.env.UI5_MAVEN_SNAPSHOT_ENDPOINT || snapshotEndpointUrl; | ||
this.#frameworkDir = frameworkDir ? path.resolve(frameworkDir) : path.join(this.#ui5HomeDir, "framework"); | ||
this.#artifactsDir = artifactsDir ? | ||
path.resolve(artifactsDir) : path.join(this.#frameworkDir, "artifacts"); | ||
this.#packagesDir = packagesDir ? | ||
path.resolve(packagesDir) : path.join(this.#frameworkDir, "packages"); | ||
this.#metadataDir = metadataDir ? | ||
path.resolve(metadataDir) : path.join(this.#frameworkDir, "metadata"); | ||
this.#stagingDir = stagingDir ? path.resolve(stagingDir) : path.join(this.#frameworkDir, "staging"); | ||
this.#lockDir = lockDir ? path.resolve(lockDir) : path.join(this.#frameworkDir, "locks"); | ||
this.#cacheDir = cacheDir ? path.resolve(cacheDir) : path.join(this.#frameworkDir, "cacache"); |
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.
There are several questions that arise here.
Which properties/settings should be within the Configuration object?
Currently, all the needed configuration options are handled here. The reasoning is that many depend on each other i.e. frameworkDir
depends on ui5HomeDir
On the other side, the core reasoning to introduce such a Configuration was to support the Snapshot URL.
Do we need default values?
According to the spec, there shouldn't be default values.
Properties could be defined/provided separately. But the way we use them internally implies that they depend on each other i.e. frameworkDir
depends on ui5HomeDir
.
Therefore, there's no ambiguity for those values and they could be easily derived.
Also, after looking into the code, it could be stated that the ui5HomeDir
should be ~/.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.
For this iteration, we have decided to go only with the necessary snapshotEndpointUrl
. The questions above would be resolved in separate iteration(s)/BLI(s).
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.
LGTM, just a small remark
7247804
to
9f224d9
Compare
a6508b6
to
b1bc70f
Compare
7c89376
to
f37a62d
Compare
Rebased to resolve conflict with main |
This feature depends on SAP/ui5-project#575 and makes the configuration of the `mavenSnapshotEndpointUrl` option possible, which is used by SAP/ui5-project#570 Co-authored-by: Merlin Beutlberger <m.beutlberger@sap.com> Co-authored-by: Günter Klatt <57760635+KlattG@users.noreply.github.com>
Introduce a new Configuration module for persisting UI5 Project specific settings.
JIRA: CPOUI5FOUNDATION-634
Complements: #570