Skip to content

Commit

Permalink
[FIX] ui5 use: Allow using versions according to Semantic Versioning
Browse files Browse the repository at this point in the history
Validation of the version is now only done within ui5-project
  • Loading branch information
matz3 committed May 29, 2020
1 parent 46d590e commit d7a9363
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
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

0 comments on commit d7a9363

Please sign in to comment.