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

[BREAKING] Rename ui5HomeDir to ui5DataDir in APIs #707

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/graph/helpers/ui5Framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export default {

if (options.versionOverride) {
version = await Resolver.resolveVersion(options.versionOverride, {
ui5HomeDir: ui5DataDir,
ui5DataDir,
cwd
});
log.info(
Expand All @@ -387,7 +387,7 @@ export default {
version,
providedLibraryMetadata,
cacheMode,
ui5HomeDir: ui5DataDir
ui5DataDir
});

let startTime;
Expand Down
10 changes: 5 additions & 5 deletions lib/ui5Framework/AbstractInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ const illegalFileNameRegExp = /[^0-9a-zA-Z\-._@/]/;

class AbstractInstaller {
/**
* @param {string} ui5HomeDir UI5 home directory location. This will be used to store packages,
* @param {string} ui5DataDir UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers.
*/
constructor(ui5HomeDir) {
constructor(ui5DataDir) {
if (new.target === AbstractInstaller) {
throw new TypeError("Class 'AbstractInstaller' is abstract");
}
if (!ui5HomeDir) {
throw new Error(`Installer: Missing parameter "ui5HomeDir"`);
if (!ui5DataDir) {
throw new Error(`Installer: Missing parameter "ui5DataDir"`);
}
this._lockDir = path.join(ui5HomeDir, "framework", "locks");
this._lockDir = path.join(ui5DataDir, "framework", "locks");
}

async _synchronize(lockName, callback) {
Expand Down
18 changes: 9 additions & 9 deletions lib/ui5Framework/AbstractResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ class AbstractResolver {
* @param {boolean} [options.sources=false] Whether to install framework libraries as sources or
* pre-built (with build manifest)
* @param {string} [options.cwd=process.cwd()] Current working directory
* @param {string} [options.ui5HomeDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* @param {string} [options.ui5DataDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers. Relative to `process.cwd()`
* @param {object.<string, @ui5/project/ui5Framework/AbstractResolver~LibraryMetadataEntry>} [options.providedLibraryMetadata]
* Resolver skips installing listed libraries and uses the dependency information to resolve their dependencies.
* <code>version</code> can be omitted in case all libraries can be resolved via the <code>providedLibraryMetadata</code>.
* Otherwise an error is thrown.
*/
/* eslint-enable max-len */
constructor({cwd, version, sources, ui5HomeDir, providedLibraryMetadata}) {
constructor({cwd, version, sources, ui5DataDir, providedLibraryMetadata}) {
if (new.target === AbstractResolver) {
throw new TypeError("Class 'AbstractResolver' is abstract");
}

// In some CI environments, the homedir might be set explicitly to a relative
// path (e.g. "./"), but tooling requires an absolute path
this._ui5HomeDir = path.resolve(
ui5HomeDir || path.join(os.homedir(), ".ui5")
this._ui5DataDir = path.resolve(
ui5DataDir || path.join(os.homedir(), ".ui5")
);
this._cwd = cwd ? path.resolve(cwd) : process.cwd();
this._version = version;
Expand Down Expand Up @@ -205,21 +205,21 @@ class AbstractResolver {
};
}

static async resolveVersion(version, {ui5HomeDir, cwd} = {}) {
static async resolveVersion(version, {ui5DataDir, cwd} = {}) {
// Don't allow nullish values
// An empty string is a valid semver range that converts to "*", which should not be supported
if (!version) {
throw new Error(`Framework version specifier "${version}" is incorrect or not supported`);
}

const spec = await this._getVersionSpec(version, {ui5HomeDir, cwd});
const spec = await this._getVersionSpec(version, {ui5DataDir, cwd});

// For all invalid cases which are not explicitly handled in _getVersionSpec
if (!spec) {
throw new Error(`Framework version specifier "${version}" is incorrect or not supported`);
}

const versions = await this.fetchAllVersions({ui5HomeDir, cwd});
const versions = await this.fetchAllVersions({ui5DataDir, cwd});
const resolvedVersion = semver.maxSatisfying(versions, spec, {
// Allow ranges that end with -SNAPSHOT to match any -SNAPSHOT version
// like a normal version in order to support ranges like 1.x.x-SNAPSHOT.
Expand All @@ -246,7 +246,7 @@ class AbstractResolver {
return resolvedVersion;
}

static async _getVersionSpec(version, {ui5HomeDir, cwd}) {
static async _getVersionSpec(version, {ui5DataDir, cwd}) {
if (this._isSnapshotVersionOrRange(version)) {
const versionMatch = version.match(VERSION_RANGE_REGEXP);
if (versionMatch) {
Expand All @@ -268,7 +268,7 @@ class AbstractResolver {
return null;
}

const allTags = await this.fetchAllTags({ui5HomeDir, cwd});
const allTags = await this.fetchAllTags({ui5DataDir, cwd});

if (!allTags) {
// Resolver doesn't support tags (e.g. Sapui5MavenSnapshotResolver)
Expand Down
10 changes: 5 additions & 5 deletions lib/ui5Framework/Openui5Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Openui5Resolver extends AbstractResolver {
* @param {*} options options
* @param {string} options.version OpenUI5 version to use
* @param {string} [options.cwd=process.cwd()] Working directory to resolve configurations like .npmrc
* @param {string} [options.ui5HomeDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* @param {string} [options.ui5DataDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers. Relative to `process.cwd()`
* @param {string} [options.cacheDir] Where to store temp/cached packages.
* @param {string} [options.packagesDir] Where to install packages
Expand All @@ -31,7 +31,7 @@ class Openui5Resolver extends AbstractResolver {

this._installer = new Installer({
cwd: this._cwd,
ui5HomeDir: this._ui5HomeDir,
ui5DataDir: this._ui5DataDir,
cacheDir, packagesDir, stagingDir
});
this._loadLibraryMetadata = Object.create(null);
Expand Down Expand Up @@ -94,11 +94,11 @@ class Openui5Resolver extends AbstractResolver {
return installer.fetchPackageDistTags({pkgName: OPENUI5_CORE_PACKAGE});
}

static _getInstaller({ui5HomeDir, cwd} = {}) {
static _getInstaller({ui5DataDir, cwd} = {}) {
return new Installer({
cwd: cwd ? path.resolve(cwd) : process.cwd(),
ui5HomeDir:
ui5HomeDir ? path.resolve(ui5HomeDir) :
ui5DataDir:
ui5DataDir ? path.resolve(ui5DataDir) :
path.join(os.homedir(), ".ui5")
});
}
Expand Down
10 changes: 5 additions & 5 deletions lib/ui5Framework/Sapui5MavenSnapshotResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Sapui5MavenSnapshotResolver extends AbstractResolver {
* @param {boolean} [options.sources=false] Whether to install framework libraries as sources or
* pre-built (with build manifest)
* @param {string} [options.cwd=process.cwd()] Current working directory
* @param {string} [options.ui5HomeDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* @param {string} [options.ui5DataDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers. Relative to `process.cwd()`
* @param {module:@ui5/project/ui5Framework/maven/CacheMode} [options.cacheMode=Default]
* Cache mode to use
Expand All @@ -45,7 +45,7 @@ class Sapui5MavenSnapshotResolver extends AbstractResolver {
} = options;

this._installer = new Installer({
ui5HomeDir: this._ui5HomeDir,
ui5DataDir: this._ui5DataDir,
snapshotEndpointUrlCb:
Sapui5MavenSnapshotResolver._createSnapshotEndpointUrlCallback(options.snapshotEndpointUrl),
cacheMode,
Expand Down Expand Up @@ -144,11 +144,11 @@ class Sapui5MavenSnapshotResolver extends AbstractResolver {
};
}

static async fetchAllVersions({ui5HomeDir, cwd, snapshotEndpointUrl} = {}) {
static async fetchAllVersions({ui5DataDir, cwd, snapshotEndpointUrl} = {}) {
const installer = new Installer({
cwd: cwd ? path.resolve(cwd) : process.cwd(),
ui5HomeDir: path.resolve(
ui5HomeDir || path.join(os.homedir(), ".ui5")
ui5DataDir: path.resolve(
ui5DataDir || path.join(os.homedir(), ".ui5")
),
snapshotEndpointUrlCb: Sapui5MavenSnapshotResolver._createSnapshotEndpointUrlCallback(snapshotEndpointUrl),
});
Expand Down
10 changes: 5 additions & 5 deletions lib/ui5Framework/Sapui5Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Sapui5Resolver extends AbstractResolver {
* @param {*} options options
* @param {string} options.version SAPUI5 version to use
* @param {string} [options.cwd=process.cwd()] Working directory to resolve configurations like .npmrc
* @param {string} [options.ui5HomeDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* @param {string} [options.ui5DataDir="~/.ui5"] UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers. Relative to `process.cwd()`
* @param {string} [options.cacheDir] Where to store temp/cached packages.
* @param {string} [options.packagesDir] Where to install packages
Expand All @@ -34,7 +34,7 @@ class Sapui5Resolver extends AbstractResolver {

this._installer = new Installer({
cwd: this._cwd,
ui5HomeDir: this._ui5HomeDir,
ui5DataDir: this._ui5DataDir,
cacheDir, packagesDir, stagingDir
});
this._loadDistMetadata = null;
Expand Down Expand Up @@ -115,11 +115,11 @@ class Sapui5Resolver extends AbstractResolver {
return installer.fetchPackageDistTags({pkgName: DIST_PKG_NAME});
}

static _getInstaller({ui5HomeDir, cwd} = {}) {
static _getInstaller({ui5DataDir, cwd} = {}) {
return new Installer({
cwd: cwd ? path.resolve(cwd) : process.cwd(),
ui5HomeDir:
ui5HomeDir ? path.resolve(ui5HomeDir) :
ui5DataDir:
ui5DataDir ? path.resolve(ui5DataDir) :
path.join(os.homedir(), ".ui5")
});
}
Expand Down
14 changes: 7 additions & 7 deletions lib/ui5Framework/maven/Installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ const CACHE_TIME = 32400000; // 9 hours
class Installer extends AbstractInstaller {
/**
* @param {object} parameters Parameters
* @param {string} parameters.ui5HomeDir UI5 home directory location. This will be used to store packages,
* @param {string} parameters.ui5DataDir UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers.
* @param {Function} parameters.snapshotEndpointUrlCb Callback that returns a Promise <string>,
* resolving to the Maven repository URL.
* Example: <code>https://registry.corp/vendor/build-snapshots/</code>
* @param {module:@ui5/project/ui5Framework/maven/CacheMode} [parameters.cacheMode=Default] Cache mode to use
*/
constructor({ui5HomeDir, snapshotEndpointUrlCb, cacheMode = CacheMode.Default}) {
super(ui5HomeDir);
constructor({ui5DataDir, snapshotEndpointUrlCb, cacheMode = CacheMode.Default}) {
super(ui5DataDir);

this._artifactsDir = path.join(ui5HomeDir, "framework", "artifacts");
this._packagesDir = path.join(ui5HomeDir, "framework", "packages");
this._metadataDir = path.join(ui5HomeDir, "framework", "metadata");
this._stagingDir = path.join(ui5HomeDir, "framework", "staging");
this._artifactsDir = path.join(ui5DataDir, "framework", "artifacts");
this._packagesDir = path.join(ui5DataDir, "framework", "packages");
this._metadataDir = path.join(ui5DataDir, "framework", "metadata");
this._stagingDir = path.join(ui5DataDir, "framework", "staging");

this._cacheMode = cacheMode;
this._snapshotEndpointUrlCb = snapshotEndpointUrlCb;
Expand Down
18 changes: 9 additions & 9 deletions lib/ui5Framework/npm/Installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ class Installer extends AbstractInstaller {
/**
* @param {object} parameters Parameters
* @param {string} parameters.cwd Current working directory
* @param {string} parameters.ui5HomeDir UI5 home directory location. This will be used to store packages,
* @param {string} parameters.ui5DataDir UI5 home directory location. This will be used to store packages,
* metadata and configuration used by the resolvers.
* @param {string} [parameters.packagesDir="${ui5HomeDir}/framework/packages"] Where to install packages
* @param {string} [parameters.stagingDir="${ui5HomeDir}/framework/staging"] The staging directory for the packages
* @param {string} [parameters.cacheDir="${ui5HomeDir}/framework/cacache"] Where to store temp/cached packages.
* @param {string} [parameters.packagesDir="${ui5DataDir}/framework/packages"] Where to install packages
* @param {string} [parameters.stagingDir="${ui5DataDir}/framework/staging"] The staging directory for the packages
* @param {string} [parameters.cacheDir="${ui5DataDir}/framework/cacache"] Where to store temp/cached packages.
*/
constructor({cwd, ui5HomeDir, packagesDir, stagingDir, cacheDir}) {
super(ui5HomeDir);
constructor({cwd, ui5DataDir, packagesDir, stagingDir, cacheDir}) {
super(ui5DataDir);
if (!cwd) {
throw new Error(`Installer: Missing parameter "cwd"`);
}
this._packagesDir = packagesDir ?
path.resolve(packagesDir) : path.join(ui5HomeDir, "framework", "packages");
path.resolve(packagesDir) : path.join(ui5DataDir, "framework", "packages");

log.verbose(`Installing to: ${this._packagesDir}`);

this._cwd = cwd;
this._caCacheDir = cacheDir ?
path.resolve(cacheDir) : path.join(ui5HomeDir, "framework", "cacache");
path.resolve(cacheDir) : path.join(ui5DataDir, "framework", "cacache");
this._stagingDir = stagingDir ?
path.resolve(stagingDir) : path.join(ui5HomeDir, "framework", "staging");
path.resolve(stagingDir) : path.join(ui5DataDir, "framework", "staging");
}

getRegistry() {
Expand Down
Loading
Loading