@sap-ux/create 0.5.114 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/cli/add/cards-editor.js +1 -1
- package/dist/cli/add/html.d.ts +8 -0
- package/dist/cli/add/html.js +70 -0
- package/dist/cli/add/index.js +3 -0
- package/dist/cli/add/mockserver-config.js +1 -1
- package/dist/cli/add/navigation-config.js +1 -1
- package/dist/cli/add/smartlinks-config.js +1 -1
- package/dist/cli/remove/mockserver-config.js +1 -1
- package/dist/validation/validation.d.ts +2 -1
- package/dist/validation/validation.js +23 -10
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -21,6 +21,12 @@ npx sap-ux
|
|
|
21
21
|
## add
|
|
22
22
|
Calling `sap-ux add` allows adding a feature to a project.
|
|
23
23
|
|
|
24
|
+
### html
|
|
25
|
+
Calling `sap-ux add html` will add html files for local preview and testing to the project. It will use the configuration from the `ui5.yaml` as default, as provided by the `fiori-tools-preview` or `preview-middleware` e.g.:
|
|
26
|
+
```sh
|
|
27
|
+
sap-ux change add html ui5-test.yaml
|
|
28
|
+
```
|
|
29
|
+
|
|
24
30
|
## change
|
|
25
31
|
Calling `sap-ux change` allows changing a feature of a project.
|
|
26
32
|
|
|
@@ -44,7 +44,7 @@ function addCardsEditorConfig(basePath, simulate, skipInstall) {
|
|
|
44
44
|
const logger = (0, tracing_1.getLogger)();
|
|
45
45
|
try {
|
|
46
46
|
logger.debug(`Called add cards-editor-config for path '${basePath}', simulate is '${simulate}'`);
|
|
47
|
-
(0, validation_1.validateBasePath)(basePath);
|
|
47
|
+
yield (0, validation_1.validateBasePath)(basePath);
|
|
48
48
|
const fs = yield (0, cards_editor_config_writer_1.enableCardsEditor)(basePath);
|
|
49
49
|
if (!simulate) {
|
|
50
50
|
yield new Promise((resolve) => fs.commit(resolve));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Adds a command to add the virtual html files hosted by the preview middleware to the file system.
|
|
4
|
+
*
|
|
5
|
+
* @param cmd - commander command for adding navigation inbounds config command
|
|
6
|
+
*/
|
|
7
|
+
export declare function addAddHtmlFilesCmd(cmd: Command): void;
|
|
8
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.addAddHtmlFilesCmd = void 0;
|
|
13
|
+
const tracing_1 = require("../../tracing");
|
|
14
|
+
const validation_1 = require("../../validation");
|
|
15
|
+
const preview_middleware_1 = require("@sap-ux/preview-middleware");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
18
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
19
|
+
const mem_fs_1 = require("mem-fs");
|
|
20
|
+
/**
|
|
21
|
+
* Adds a command to add the virtual html files hosted by the preview middleware to the file system.
|
|
22
|
+
*
|
|
23
|
+
* @param cmd - commander command for adding navigation inbounds config command
|
|
24
|
+
*/
|
|
25
|
+
function addAddHtmlFilesCmd(cmd) {
|
|
26
|
+
cmd.command('html [path]')
|
|
27
|
+
.option('-c, --config <string>', 'Path to project configuration file in YAML format', 'ui5.yaml')
|
|
28
|
+
.option('-s, --simulate', 'simulate only do not write config; sets also --verbose')
|
|
29
|
+
.option('-v, --verbose', 'show verbose information')
|
|
30
|
+
.action((path, options) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (options.verbose === true || options.simulate) {
|
|
32
|
+
(0, tracing_1.setLogLevelVerbose)();
|
|
33
|
+
}
|
|
34
|
+
yield addHtmlFiles(path || process.cwd(), !!options.simulate, options.config);
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
exports.addAddHtmlFilesCmd = addAddHtmlFilesCmd;
|
|
38
|
+
/**
|
|
39
|
+
* Adds the virtual html files hosted by the preview middleware to the file system.
|
|
40
|
+
*
|
|
41
|
+
* @param basePath - path to application root
|
|
42
|
+
* @param simulate - if true, do not write but just show what would be change; otherwise write
|
|
43
|
+
* @param yamlPath - path to the ui5*.yaml file
|
|
44
|
+
*/
|
|
45
|
+
function addHtmlFiles(basePath, simulate, yamlPath) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const logger = (0, tracing_1.getLogger)();
|
|
49
|
+
try {
|
|
50
|
+
logger.debug(`Called add html for path '${basePath}', simulate is '${simulate}'`);
|
|
51
|
+
const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
|
|
52
|
+
yield (0, validation_1.validateBasePath)(basePath, ui5ConfigPath);
|
|
53
|
+
const fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
54
|
+
const ui5Conf = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
|
|
55
|
+
const preview = (_a = ui5Conf.findCustomMiddleware('fiori-tools-preview')) !== null && _a !== void 0 ? _a : ui5Conf.findCustomMiddleware('preview-middleware');
|
|
56
|
+
yield (0, preview_middleware_1.generatePreviewFiles)(basePath, (_b = preview === null || preview === void 0 ? void 0 : preview.configuration) !== null && _b !== void 0 ? _b : {}, fs, logger);
|
|
57
|
+
if (!simulate) {
|
|
58
|
+
yield new Promise((resolve) => fs.commit(resolve));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
yield (0, tracing_1.traceChanges)(fs);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
logger.error(`Error while executing add html '${error.message}'`);
|
|
66
|
+
logger.debug(error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=html.js.map
|
package/dist/cli/add/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const smartlinks_config_1 = require("./smartlinks-config");
|
|
|
7
7
|
const cds_plugin_ui_1 = require("./cds-plugin-ui");
|
|
8
8
|
const navigation_config_1 = require("./navigation-config");
|
|
9
9
|
const cards_editor_1 = require("./cards-editor");
|
|
10
|
+
const html_1 = require("./html");
|
|
10
11
|
/**
|
|
11
12
|
* Return 'create-fiori add *' commands. Commands include also the handler action.
|
|
12
13
|
*
|
|
@@ -24,6 +25,8 @@ function getAddCommands() {
|
|
|
24
25
|
(0, navigation_config_1.addInboundNavigationConfigCommand)(addCommands);
|
|
25
26
|
// create-fiori add cards-editor
|
|
26
27
|
(0, cards_editor_1.addCardsEditorConfigCommand)(addCommands);
|
|
28
|
+
// create-fiori add html
|
|
29
|
+
(0, html_1.addAddHtmlFilesCmd)(addCommands);
|
|
27
30
|
return addCommands;
|
|
28
31
|
}
|
|
29
32
|
exports.getAddCommands = getAddCommands;
|
|
@@ -49,7 +49,7 @@ function addMockserverConfig(basePath, simulate, skipInstall, interactive) {
|
|
|
49
49
|
const logger = (0, tracing_1.getLogger)();
|
|
50
50
|
try {
|
|
51
51
|
logger.debug(`Called add mockserver-config for path '${basePath}', simulate is '${simulate}', skip install is '${skipInstall}'`);
|
|
52
|
-
(0, validation_1.validateBasePath)(basePath);
|
|
52
|
+
yield (0, validation_1.validateBasePath)(basePath);
|
|
53
53
|
const webappPath = yield (0, project_access_1.getWebappPath)(basePath);
|
|
54
54
|
const config = { webappPath };
|
|
55
55
|
if (interactive) {
|
|
@@ -41,7 +41,7 @@ function addInboundNavigationConfig(basePath, simulate) {
|
|
|
41
41
|
const logger = (0, tracing_1.getLogger)();
|
|
42
42
|
try {
|
|
43
43
|
logger.debug(`Called add inbound navigation-config for path '${basePath}', simulate is '${simulate}'`);
|
|
44
|
-
(0, validation_1.validateBasePath)(basePath);
|
|
44
|
+
yield (0, validation_1.validateBasePath)(basePath);
|
|
45
45
|
const { config, fs } = yield (0, app_config_writer_1.promptInboundNavigationConfig)(basePath);
|
|
46
46
|
if (config) {
|
|
47
47
|
yield (0, app_config_writer_1.generateInboundNavigationConfig)(basePath, config, true, fs);
|
|
@@ -41,7 +41,7 @@ function addSmartLinksConfig(basePath, simulate) {
|
|
|
41
41
|
const logger = (0, tracing_1.getLogger)();
|
|
42
42
|
try {
|
|
43
43
|
logger.debug(`Called add smartlinks-config for path '${basePath}', simulate is '${simulate}'`);
|
|
44
|
-
(0, validation_1.validateBasePath)(basePath);
|
|
44
|
+
yield (0, validation_1.validateBasePath)(basePath);
|
|
45
45
|
const config = yield (0, app_config_writer_1.getSmartLinksTargetFromPrompt)(basePath, logger);
|
|
46
46
|
const fs = yield (0, app_config_writer_1.generateSmartLinksConfig)(basePath, config, logger);
|
|
47
47
|
yield (0, tracing_1.traceChanges)(fs);
|
|
@@ -45,7 +45,7 @@ function removeMockserverConfiguration(basePath, force) {
|
|
|
45
45
|
const logger = (0, tracing_1.getLogger)();
|
|
46
46
|
try {
|
|
47
47
|
logger.debug(`Called remove mockserver-config for path '${basePath}', force is '${force}'`);
|
|
48
|
-
(0, validation_1.validateBasePath)(basePath);
|
|
48
|
+
yield (0, validation_1.validateBasePath)(basePath);
|
|
49
49
|
const fs = (0, mockserver_config_writer_1.removeMockserverConfig)(basePath);
|
|
50
50
|
yield (0, tracing_1.traceChanges)(fs);
|
|
51
51
|
const hasDeletions = (0, validation_1.hasFileDeletes)(fs);
|
|
@@ -3,8 +3,9 @@ import type { Editor } from 'mem-fs-editor';
|
|
|
3
3
|
* Validate base path of app, throw error if file is missing.
|
|
4
4
|
*
|
|
5
5
|
* @param basePath - base path of the app, where package.json and ui5.yaml resides
|
|
6
|
+
* @param ui5YamlPath - optional path to ui5.yaml file
|
|
6
7
|
*/
|
|
7
|
-
export declare function validateBasePath(basePath: string): void
|
|
8
|
+
export declare function validateBasePath(basePath: string, ui5YamlPath?: string): Promise<void>;
|
|
8
9
|
/**
|
|
9
10
|
* Return if an instance of mem-fs editor recorded any deletion.
|
|
10
11
|
*
|
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.hasFileDeletes = exports.validateBasePath = void 0;
|
|
13
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
4
14
|
const fs_1 = require("fs");
|
|
5
15
|
const path_1 = require("path");
|
|
6
16
|
/**
|
|
7
17
|
* Validate base path of app, throw error if file is missing.
|
|
8
18
|
*
|
|
9
19
|
* @param basePath - base path of the app, where package.json and ui5.yaml resides
|
|
20
|
+
* @param ui5YamlPath - optional path to ui5.yaml file
|
|
10
21
|
*/
|
|
11
|
-
function validateBasePath(basePath) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
function validateBasePath(basePath, ui5YamlPath) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const packageJsonPath = (0, path_1.join)(basePath, 'package.json');
|
|
25
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
26
|
+
throw Error(`Required file '${packageJsonPath}' does not exist.`);
|
|
27
|
+
}
|
|
28
|
+
ui5YamlPath !== null && ui5YamlPath !== void 0 ? ui5YamlPath : (ui5YamlPath = (0, path_1.join)(basePath, 'ui5.yaml'));
|
|
29
|
+
const webappPath = yield (0, project_access_1.getWebappPath)(basePath);
|
|
30
|
+
if (!(0, fs_1.existsSync)(ui5YamlPath) && !(0, fs_1.existsSync)(webappPath)) {
|
|
31
|
+
throw Error(`There must be either a folder '${webappPath}' or a config file '${ui5YamlPath}'`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
21
34
|
}
|
|
22
35
|
exports.validateBasePath = validateBasePath;
|
|
23
36
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/create",
|
|
3
3
|
"description": "SAP Fiori tools module to add or remove features",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -37,8 +37,9 @@
|
|
|
37
37
|
"@sap-ux/inquirer-common": "0.3.1",
|
|
38
38
|
"@sap-ux/logger": "0.5.1",
|
|
39
39
|
"@sap-ux/mockserver-config-writer": "0.5.8",
|
|
40
|
-
"@sap-ux/
|
|
40
|
+
"@sap-ux/preview-middleware": "0.15.0",
|
|
41
41
|
"@sap-ux/system-access": "0.4.5",
|
|
42
|
+
"@sap-ux/project-access": "1.22.3",
|
|
42
43
|
"@sap-ux/ui5-config": "0.22.10"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|