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

[FIX] ui5 use: Allow using versions according to Semantic Versioning #341

Merged
merged 1 commit into from
May 29, 2020
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
12 changes: 5 additions & 7 deletions lib/cli/commands/use.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ useCommand.builder = function(cli) {
.example("$0 use openui5", "Use OpenUI5 without a version (or use existing version)");
};

const versionRegExp = /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/;

function parseFrameworkInfo(frameworkInfo) {
const parts = frameworkInfo.split("@");
if (parts.length > 2) {
Expand All @@ -33,15 +31,15 @@ function parseFrameworkInfo(frameworkInfo) {
if (!nameOrVersion) {
throw new Error("Invalid framework info: " + frameworkInfo);
}
if (nameOrVersion === "latest" || versionRegExp.test(nameOrVersion)) {
if (["sapui5", "openui5"].includes(nameOrVersion.toLowerCase())) {
return {
name: null,
version: nameOrVersion
name: nameOrVersion,
version: null
};
} else {
return {
name: nameOrVersion,
version: null
name: null,
version: nameOrVersion
};
}
} else {
Expand Down
20 changes: 20 additions & 0 deletions test/lib/cli/commands/use.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ test.serial("Accepts framework name and version (OpenUI5@1.76)", async (t) => {
});
});

test.serial("Accepts framework name and version (SAPUI5@1.79.0-SNAPSHOT)", async (t) => {
await assertUseHandler(t, {
argv: {"framework-info": "SAPUI5@1.79.0-SNAPSHOT"},
expectedFrameworkOptions: {
name: "SAPUI5",
version: "1.79.0-SNAPSHOT"
}
});
});

test.serial("Accepts framework name and version (OpenUI5@1.79.0-SNAPSHOT)", async (t) => {
await assertUseHandler(t, {
argv: {"framework-info": "OpenUI5@1.79.0-SNAPSHOT"},
expectedFrameworkOptions: {
name: "OpenUI5",
version: "1.79.0-SNAPSHOT"
}
});
});

test.serial("Accepts framework name and version (SAPUI5@latest)", async (t) => {
await assertUseHandler(t, {
argv: {"framework-info": "SAPUI5@latest"},
Expand Down