@sap-ux/create 0.3.0 → 0.4.0
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
CHANGED
|
@@ -3,12 +3,28 @@ Module which provides command line interface to configure features for SAP UX pr
|
|
|
3
3
|
|
|
4
4
|
To see usage, run
|
|
5
5
|
|
|
6
|
-
```
|
|
6
|
+
```sh
|
|
7
7
|
npm init @sap-ux
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
To avoid downloading and installing the module every time it is used, you might consider installing it globally or add it as `devDependency` to a project. Once installed, you can run it using
|
|
11
11
|
|
|
12
|
-
```
|
|
12
|
+
```sh
|
|
13
13
|
npx sap-ux
|
|
14
14
|
```
|
|
15
|
+
|
|
16
|
+
## add
|
|
17
|
+
Calling `npx sap-ux add` allows adding a feature to a project.
|
|
18
|
+
|
|
19
|
+
## remove
|
|
20
|
+
Calling `npx sap-ux remove` allows removing a feature to a project.
|
|
21
|
+
|
|
22
|
+
## generate
|
|
23
|
+
Calling `npx sap-ux generate` allows generating a new project.
|
|
24
|
+
|
|
25
|
+
### adaptation-project
|
|
26
|
+
Calling `npx sap-ux generate adaptation-project` allows generating a new adaptation project. Without further parameters the CLI will prompt the required parameters `id`, `reference` and `url`. To run the prompt non-interactively, it is also possible to execute
|
|
27
|
+
```sh
|
|
28
|
+
npx sap-ux generate adaptation-project --id my.adp --reference the.original.app --url http://my.sapsystem.example
|
|
29
|
+
```
|
|
30
|
+
Additional options are `--skip-install` to skip running `npm install` after the project generation and `--simulate` to only simulate the files that would be generated instead of writing them to the file system.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Add a new sub-command to generate SAP UI5 adaptation projects the given command.
|
|
4
|
+
*
|
|
5
|
+
* @param cmd main command that is to be enhanced
|
|
6
|
+
*/
|
|
7
|
+
export declare function addGenerateAdaptationProjectCommand(cmd: Command): void;
|
|
8
|
+
//# sourceMappingURL=adaptation-project.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
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.addGenerateAdaptationProjectCommand = void 0;
|
|
13
|
+
const tracing_1 = require("../../tracing");
|
|
14
|
+
const adp_tooling_1 = require("@sap-ux/adp-tooling");
|
|
15
|
+
const common_1 = require("../../common");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
/**
|
|
18
|
+
* Add a new sub-command to generate SAP UI5 adaptation projects the given command.
|
|
19
|
+
*
|
|
20
|
+
* @param cmd main command that is to be enhanced
|
|
21
|
+
*/
|
|
22
|
+
function addGenerateAdaptationProjectCommand(cmd) {
|
|
23
|
+
cmd.command('adaptation-project [path]')
|
|
24
|
+
.option('-n, --skip-install', 'skip npm install step')
|
|
25
|
+
.option('-s, --simulate', 'simulate only do not write or install')
|
|
26
|
+
.option('--id [id]', 'id of the adaptation project')
|
|
27
|
+
.option('--reference [reference]', 'id of the original application')
|
|
28
|
+
.option('--url [url]', 'url pointing to the target system containing the original app')
|
|
29
|
+
.action((path, options) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
yield generateAdaptationProject(path, Object.assign({}, options), !!options.simulate, !!options.skipInstall);
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
exports.addGenerateAdaptationProjectCommand = addGenerateAdaptationProjectCommand;
|
|
34
|
+
/**
|
|
35
|
+
* Generate an SAP UI5 adaptation project based on the given parameters.
|
|
36
|
+
*
|
|
37
|
+
* @param basePath target folder of the new project
|
|
38
|
+
* @param defaults optional defaults
|
|
39
|
+
* @param defaults.id id of the new adaptation project
|
|
40
|
+
* @param defaults.reference id of the referenced original app
|
|
41
|
+
* @param defaults.url url of the target system
|
|
42
|
+
* @param simulate if set to true, then no files will be written to the filesystem
|
|
43
|
+
* @param skipInstall if set to true then `npm i` is not executed in the new project
|
|
44
|
+
*/
|
|
45
|
+
function generateAdaptationProject(basePath, defaults, simulate, skipInstall) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const logger = (0, tracing_1.getLogger)();
|
|
48
|
+
try {
|
|
49
|
+
logger.debug(`Called generate adaptation-project for path '${basePath}', skip install is '${skipInstall}'`);
|
|
50
|
+
let config;
|
|
51
|
+
if (defaults.id && defaults.reference && defaults.url) {
|
|
52
|
+
config = {
|
|
53
|
+
app: {
|
|
54
|
+
id: defaults.id,
|
|
55
|
+
reference: defaults.reference,
|
|
56
|
+
layer: 'CUSTOMER_BASE'
|
|
57
|
+
},
|
|
58
|
+
target: {
|
|
59
|
+
url: defaults.url
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
config = yield (0, adp_tooling_1.promptGeneratorInput)(defaults);
|
|
65
|
+
}
|
|
66
|
+
if (!basePath) {
|
|
67
|
+
basePath = (0, path_1.join)(process.cwd(), config.app.id);
|
|
68
|
+
}
|
|
69
|
+
const fs = yield (0, adp_tooling_1.generate)(basePath, config);
|
|
70
|
+
if (!simulate) {
|
|
71
|
+
yield new Promise((resolve) => fs.commit(resolve));
|
|
72
|
+
if (!skipInstall) {
|
|
73
|
+
(0, common_1.runNpmInstallCommand)(basePath);
|
|
74
|
+
logger.info('Executed npm install');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
yield (0, tracing_1.traceChanges)(fs);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
logger.error(error.message);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=adaptation-project.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGenerateCommands = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const adaptation_project_1 = require("./adaptation-project");
|
|
6
|
+
/**
|
|
7
|
+
* @returns 'generate *' commands. Commands include also the handler action.
|
|
8
|
+
*/
|
|
9
|
+
function getGenerateCommands() {
|
|
10
|
+
const genCommands = new commander_1.Command('generate');
|
|
11
|
+
// create-fiori generate adaptation-project
|
|
12
|
+
(0, adaptation_project_1.addGenerateAdaptationProjectCommand)(genCommands);
|
|
13
|
+
return genCommands;
|
|
14
|
+
}
|
|
15
|
+
exports.getGenerateCommands = getGenerateCommands;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const commander_1 = require("commander");
|
|
|
7
7
|
const tracing_1 = require("../tracing");
|
|
8
8
|
const add_1 = require("./add");
|
|
9
9
|
const remove_1 = require("./remove");
|
|
10
|
+
const generate_1 = require("./generate");
|
|
10
11
|
/*
|
|
11
12
|
* We've chosen 'commander' over 'minimist' and 'yargs' for this CLI implementation. Reasons:
|
|
12
13
|
* (if it still up: https://npmtrends.com/commander-vs-minimist-vs-yargs)
|
|
@@ -44,6 +45,8 @@ function getCommanderProgram() {
|
|
|
44
45
|
const version = getVersion();
|
|
45
46
|
program.description(`Configure features for Fiori applications and projects. (${version})`);
|
|
46
47
|
program.version(version);
|
|
48
|
+
// Handler for create-fiori generate <feature> ..
|
|
49
|
+
program.addCommand((0, generate_1.getGenerateCommands)());
|
|
47
50
|
// Handler for create-fiori add <feature> ..
|
|
48
51
|
program.addCommand((0, add_1.getAddCommands)());
|
|
49
52
|
// Handler for create-fiori remove <feature> ..
|
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.4.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"commander": "9.4.0",
|
|
30
30
|
"diff": "5.1.0",
|
|
31
31
|
"prompts": "2.4.2",
|
|
32
|
-
"@sap-ux/
|
|
33
|
-
"@sap-ux/
|
|
32
|
+
"@sap-ux/adp-tooling": "0.1.0",
|
|
33
|
+
"@sap-ux/app-config-writer": "0.1.2",
|
|
34
|
+
"@sap-ux/cap-config-writer": "0.1.9",
|
|
34
35
|
"@sap-ux/logger": "0.3.7",
|
|
35
36
|
"@sap-ux/mockserver-config-writer": "0.1.7",
|
|
36
|
-
"@sap-ux/project-access": "1.10.
|
|
37
|
+
"@sap-ux/project-access": "1.10.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/diff": "5.0.2",
|