Skip to content

Commit

Permalink
[FEATURE] Add "configPath" option
Browse files Browse the repository at this point in the history
Fixes: #169
  • Loading branch information
matz3 committed Apr 9, 2020
1 parent 25f8899 commit 6f90051
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 4 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [url](#url)
- [type](#type)
- [paths](#paths)
- [configPath](#configPath)
- [mode](#mode)
- [html](#html)
- [script](#script)
Expand Down Expand Up @@ -196,6 +197,21 @@ ui5: {
}
```

### configPath
Type: `string`
Default: `"ui5.yaml"`
CLI: `--ui5.configPath`

Path to the UI5 configuration file.
It is resolved relative to the project root.

Example:
```js
ui5: {
configPath: "ui5-test.yaml"
}
```

### mode
Type: `enum` (`"html"` / `"script"`)
Default: `"html"`
Expand Down
15 changes: 11 additions & 4 deletions lib/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,14 @@ class Framework {
};
}

async setupUI5Server(basePath) {
const tree = await normalizer.generateProjectTree({
async setupUI5Server({basePath, configPath}) {
const normalizerOptions = {
cwd: basePath
});
};
if (configPath) {
normalizerOptions.configPath = path.resolve(basePath, configPath);
}
const tree = await normalizer.generateProjectTree(normalizerOptions);

const projectResourceCollections = resourceFactory.createCollectionsForTree(tree);

Expand Down Expand Up @@ -462,7 +466,10 @@ class Framework {
config.beforeMiddleware.push("ui5--pauseRequests");
config.middleware.push("ui5--serveResources");
// config.middleware.push("ui5--serveThemes");
server = await this.setupUI5Server(config.basePath);
server = await this.setupUI5Server({
basePath: config.basePath,
configPath: config.ui5.configPath
});
}

this._serveResources = server.serveResources;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = function(config) {
"use strict";

require("../karma-base.conf")(config);
config.set({

frameworks: ["ui5"],

ui5: {
configPath: require("path").resolve(__dirname, "ui5-foo.yaml")
},

reporters: ["progress"]

});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = function(config) {
"use strict";

require("../karma-base.conf")(config);
config.set({

frameworks: ["ui5"],

ui5: {
configPath: "ui5-does-not-exist.yaml"
},

reporters: ["progress"]

});
};

module.exports.assertions = function({expect, log}) {
expect(log).toContain("Failed to read configuration for project application-ui5-tooling");
expect(log).toContain("ui5-does-not-exist.yaml");
};

module.exports.shouldFail = true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = function(config) {
"use strict";

require("../karma-base.conf")(config);
config.set({

frameworks: ["ui5"],

ui5: {
configPath: "ui5-foo.yaml"
},

reporters: ["progress"]

});
};
5 changes: 5 additions & 0 deletions test/integration/application-ui5-tooling/ui5-foo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
specVersion: "2.0"
type: application
metadata:
name: test.app

0 comments on commit 6f90051

Please sign in to comment.