Skip to content

refactor: Consolidate UI5 data directory resolution into resolveUi5DataDir#1456

Open
d3xter666 wants to merge 12 commits into
mainfrom
refactor/resolve-ui5-data-dir
Open

refactor: Consolidate UI5 data directory resolution into resolveUi5DataDir#1456
d3xter666 wants to merge 12 commits into
mainfrom
refactor/resolve-ui5-data-dir

Conversation

@d3xter666

@d3xter666 d3xter666 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Introduces packages/project/lib/utils/dataDir.js with a single resolveUi5DataDir() utility that encapsulates the full resolution chain:

  1. UI5_DATA_DIR environment variable
  2. ui5DataDir from configuration file
  3. Default: ~/.ui5

Removes the duplicate getUi5DataDir() function from packages/cli/lib/framework/utils.js and migrates its callers (createFrameworkResolverInstance, frameworkResolverResolveVersion) to use resolveUi5DataDir() directly.

Consolidates and enforces the new utility accross packages

…taDir

Introduces packages/project/lib/utils/dataDir.js with a single
resolveUi5DataDir() utility that encapsulates the full resolution chain:
  1. UI5_DATA_DIR environment variable
  2. ui5DataDir from configuration file (~/.ui5rc)
  3. Default: ~/.ui5

Removes the duplicate getUi5DataDir() function from
packages/cli/lib/framework/utils.js and migrates its callers
(createFrameworkResolverInstance, frameworkResolverResolveVersion) to
use resolveUi5DataDir() directly.

The defensive fallbacks in the public Resolver/Installer APIs
(AbstractResolver, Openui5Resolver, Sapui5Resolver,
Sapui5MavenSnapshotResolver) are intentionally kept — those are
synchronous constructors that cannot call the async utility, and they
are publicly exported so external callers may pass undefined.
…ve path resolution

Renames the cwd option to projectRootPath to make its purpose explicit:
this is the root of the specific project being processed (where package.json
lives), not necessarily the shell's current working directory. When omitted,
falls back to process.cwd().

Callers in createFrameworkResolverInstance and frameworkResolverResolveVersion
now thread the project root through so relative ui5DataDir values in config
are resolved against the correct base directory.
…i5DataDir

Two call sites that duplicated the env→config→default resolution logic
are migrated to resolveUi5DataDir({projectRootPath}):

- packages/project/lib/graph/helpers/ui5Framework.js:
  enrichProjectGraph resolves ui5DataDir via resolveUi5DataDir using
  rootProject.getRootPath() as projectRootPath, then passes it to
  the framework Resolver. Configuration and os imports removed.

- packages/project/lib/build/cache/CacheManager.create():
  The no-ui5DataDir path now delegates to resolveUi5DataDir instead of
  inlining env/config/default logic. The explicit ui5DataDir option
  still resolves against cwd for backward compatibility. os and
  Configuration imports removed.

Tests updated: resolveUi5DataDir stub added to ui5Framework.js esmocks
so the stub mirrors the real resolution logic (including env and config
stubs), and package-exports count updated.
…i5DataDir

Two call sites that duplicated the env→config→default resolution logic
are migrated to resolveUi5DataDir({projectRootPath}):

- packages/project/lib/graph/helpers/ui5Framework.js:
  enrichProjectGraph resolves ui5DataDir via resolveUi5DataDir using
  rootProject.getRootPath() as projectRootPath, then passes it to
  the framework Resolver. Configuration and os imports removed.

- packages/project/lib/build/cache/CacheManager.create():
  The no-ui5DataDir path now delegates to resolveUi5DataDir instead of
  inlining env/config/default logic. The explicit ui5DataDir option
  still resolves against cwd for backward compatibility. os and
  Configuration imports removed.

Tests updated: resolveUi5DataDir stub added to ui5Framework.js esmocks
so the stub mirrors the real resolution logic (including env and config
stubs), and package-exports count updated.
@d3xter666
d3xter666 force-pushed the refactor/resolve-ui5-data-dir branch from 95e6631 to b449a91 Compare July 17, 2026 11:26
Replace hardcoded POSIX absolute paths (/my/project, /custom/data/dir,
etc.) with path.resolve(os.tmpdir(), ...) so assertions hold on all
platforms. On Windows, /foo is not an absolute path — it is relative
to the current drive root — causing four tests to fail.
@d3xter666
d3xter666 force-pushed the refactor/resolve-ui5-data-dir branch from b449a91 to b091c77 Compare July 17, 2026 11:27
- Use path.resolve instead of path.join for the default ~/.ui5 fallback
  so the result is absolute even when os.homedir() returns a relative
  path (e.g. "./" in some CI/container environments).

- Add edge-case test that asserts absoluteness when HOME is relative.

- Fix CLI framework/utils tests: stubs resolving undefined reflected
  old behavior where no ui5DataDir meant undefined; add clarifying
  comments that these tests validate stub wiring, not real resolution.

- Add utils/dataDir to the explicit API parity list in package-exports
  test so a path/mapping regression would be caught by a specific test.
- cli/framework/utils.js: stub now resolves the real default path
  (path.join(os.homedir(), ".ui5")) instead of undefined, matching
  the production contract of resolveUi5DataDir.

- graph/helpers/ui5Framework.js: stub and assertions use path.resolve
  instead of path.join for the default ~/.ui5 path, matching the
  stricter absolute-path guarantee of the implementation.
The stub for resolveUi5DataDir does not need to compute a real
filesystem path — it just needs an opaque value that flows through
correctly. Replace path.join(os.homedir(), '.ui5') with the string
literal 'my-default-ui5-data-dir' and remove the unused os and path
imports.
@d3xter666
d3xter666 marked this pull request as ready for review July 17, 2026 14:58
@d3xter666
d3xter666 requested a review from a team July 17, 2026 14:58
@RandomByte

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants