@sap-ux/create 0.6.8 → 0.7.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.
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addCardsEditorConfigCommand = void 0;
13
4
  const cards_editor_config_writer_1 = require("@sap-ux/cards-editor-config-writer");
@@ -24,12 +15,12 @@ function addCardsEditorConfigCommand(cmd) {
24
15
  .option('-n, --skip-install', 'skip npm install step')
25
16
  .option('-s, --simulate', 'simulate only do not write config; sets also --verbose')
26
17
  .option('-v, --verbose', 'show verbose information')
27
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
18
+ .action(async (path, options) => {
28
19
  if (options.verbose === true || options.simulate) {
29
20
  (0, tracing_1.setLogLevelVerbose)();
30
21
  }
31
- yield addCardsEditorConfig(path || process.cwd(), !!options.simulate, !!options.skipInstall);
32
- }));
22
+ await addCardsEditorConfig(path || process.cwd(), !!options.simulate, !!options.skipInstall);
23
+ });
33
24
  }
34
25
  exports.addCardsEditorConfigCommand = addCardsEditorConfigCommand;
35
26
  /**
@@ -39,28 +30,26 @@ exports.addCardsEditorConfigCommand = addCardsEditorConfigCommand;
39
30
  * @param simulate - if true, do not write but just show what would be change; otherwise write
40
31
  * @param skipInstall - if true, do not run npm install
41
32
  */
42
- function addCardsEditorConfig(basePath, simulate, skipInstall) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const logger = (0, tracing_1.getLogger)();
45
- try {
46
- logger.debug(`Called add cards-editor-config for path '${basePath}', simulate is '${simulate}'`);
47
- yield (0, validation_1.validateBasePath)(basePath);
48
- const fs = yield (0, cards_editor_config_writer_1.enableCardsEditor)(basePath);
49
- if (!simulate) {
50
- yield new Promise((resolve) => fs.commit(resolve));
51
- if (!skipInstall) {
52
- (0, common_1.runNpmInstallCommand)(basePath);
53
- logger.info('Executed npm install');
54
- }
55
- }
56
- else {
57
- yield (0, tracing_1.traceChanges)(fs);
33
+ async function addCardsEditorConfig(basePath, simulate, skipInstall) {
34
+ const logger = (0, tracing_1.getLogger)();
35
+ try {
36
+ logger.debug(`Called add cards-editor-config for path '${basePath}', simulate is '${simulate}'`);
37
+ await (0, validation_1.validateBasePath)(basePath);
38
+ const fs = await (0, cards_editor_config_writer_1.enableCardsEditor)(basePath);
39
+ if (!simulate) {
40
+ await new Promise((resolve) => fs.commit(resolve));
41
+ if (!skipInstall) {
42
+ (0, common_1.runNpmInstallCommand)(basePath);
43
+ logger.info('Executed npm install');
58
44
  }
59
45
  }
60
- catch (error) {
61
- logger.error(`Error while executing add cards editor configuration '${error.message}'`);
62
- logger.debug(error);
46
+ else {
47
+ await (0, tracing_1.traceChanges)(fs);
63
48
  }
64
- });
49
+ }
50
+ catch (error) {
51
+ logger.error(`Error while executing add cards editor configuration '${error.message}'`);
52
+ logger.debug(error);
53
+ }
65
54
  }
66
55
  //# sourceMappingURL=cards-editor.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addAddCdsPluginUi5Command = void 0;
13
4
  const path_1 = require("path");
@@ -24,12 +15,12 @@ function addAddCdsPluginUi5Command(cmd) {
24
15
  .option('-n, --skip-install', 'skip npm install step')
25
16
  .option('-s, --simulate', 'simulate only, do not write or install; sets also --verbose')
26
17
  .option('-v, --verbose', 'show verbose information')
27
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
18
+ .action(async (path, options) => {
28
19
  if (options.verbose === true || options.simulate) {
29
20
  (0, tracing_1.setLogLevelVerbose)();
30
21
  }
31
- yield addCdsPluginUi5(path || process.cwd(), !!options.simulate, !!options.skipInstall);
32
- }));
22
+ await addCdsPluginUi5(path || process.cwd(), !!options.simulate, !!options.skipInstall);
23
+ });
33
24
  }
34
25
  exports.addAddCdsPluginUi5Command = addAddCdsPluginUi5Command;
35
26
  /**
@@ -39,35 +30,33 @@ exports.addAddCdsPluginUi5Command = addAddCdsPluginUi5Command;
39
30
  * @param simulate - if true, do not write but just show what would be change; otherwise write
40
31
  * @param skipInstall - if true, skip execution of npm install
41
32
  */
42
- function addCdsPluginUi5(basePath, simulate, skipInstall) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- const logger = (0, tracing_1.getLogger)();
45
- try {
46
- logger.debug(`Called add cds-plugin-ui5 for path '${basePath}', simulate is '${simulate}', skip install is '${skipInstall}'`);
47
- const fs = yield (0, cap_config_writer_1.enableCdsUi5Plugin)(basePath);
48
- yield (0, tracing_1.traceChanges)(fs);
49
- if (!simulate) {
50
- fs.commit(() => {
51
- logger.info(`Changes to enable cds-plugin-ui5 written`);
52
- if (skipInstall) {
53
- logger.warn('To finish enablement of cds-plugin-ui5 run commands:');
54
- const relPath = (0, path_1.relative)(basePath, process.cwd());
55
- if (relPath) {
56
- logger.info(`cd ${relPath}`);
57
- }
58
- logger.info('npm install');
59
- }
60
- else {
61
- logger.debug('Running npm install command');
62
- (0, common_1.runNpmInstallCommand)(basePath);
33
+ async function addCdsPluginUi5(basePath, simulate, skipInstall) {
34
+ const logger = (0, tracing_1.getLogger)();
35
+ try {
36
+ logger.debug(`Called add cds-plugin-ui5 for path '${basePath}', simulate is '${simulate}', skip install is '${skipInstall}'`);
37
+ const fs = await (0, cap_config_writer_1.enableCdsUi5Plugin)(basePath);
38
+ await (0, tracing_1.traceChanges)(fs);
39
+ if (!simulate) {
40
+ fs.commit(() => {
41
+ logger.info(`Changes to enable cds-plugin-ui5 written`);
42
+ if (skipInstall) {
43
+ logger.warn('To finish enablement of cds-plugin-ui5 run commands:');
44
+ const relPath = (0, path_1.relative)(basePath, process.cwd());
45
+ if (relPath) {
46
+ logger.info(`cd ${relPath}`);
63
47
  }
64
- });
65
- }
48
+ logger.info('npm install');
49
+ }
50
+ else {
51
+ logger.debug('Running npm install command');
52
+ (0, common_1.runNpmInstallCommand)(basePath);
53
+ }
54
+ });
66
55
  }
67
- catch (error) {
68
- logger.error(`Error while adding cds-plugin-ui5 '${error === null || error === void 0 ? void 0 : error.toString()}'`);
69
- logger.debug(error);
70
- }
71
- });
56
+ }
57
+ catch (error) {
58
+ logger.error(`Error while adding cds-plugin-ui5 '${error?.toString()}'`);
59
+ logger.debug(error);
60
+ }
72
61
  }
73
62
  //# sourceMappingURL=cds-plugin-ui.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addAddHtmlFilesCmd = void 0;
13
4
  const tracing_1 = require("../../tracing");
@@ -27,12 +18,12 @@ function addAddHtmlFilesCmd(cmd) {
27
18
  .option('-c, --config <string>', 'Path to project configuration file in YAML format', 'ui5.yaml')
28
19
  .option('-s, --simulate', 'simulate only do not write config; sets also --verbose')
29
20
  .option('-v, --verbose', 'show verbose information')
30
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
21
+ .action(async (path, options) => {
31
22
  if (options.verbose === true || options.simulate) {
32
23
  (0, tracing_1.setLogLevelVerbose)();
33
24
  }
34
- yield addHtmlFiles(path || process.cwd(), !!options.simulate, options.config);
35
- }));
25
+ await addHtmlFiles(path || process.cwd(), !!options.simulate, options.config);
26
+ });
36
27
  }
37
28
  exports.addAddHtmlFilesCmd = addAddHtmlFilesCmd;
38
29
  /**
@@ -42,29 +33,27 @@ exports.addAddHtmlFilesCmd = addAddHtmlFilesCmd;
42
33
  * @param simulate - if true, do not write but just show what would be change; otherwise write
43
34
  * @param yamlPath - path to the ui5*.yaml file
44
35
  */
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
- }
36
+ async function addHtmlFiles(basePath, simulate, yamlPath) {
37
+ const logger = (0, tracing_1.getLogger)();
38
+ try {
39
+ logger.debug(`Called add html for path '${basePath}', simulate is '${simulate}'`);
40
+ const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
41
+ await (0, validation_1.validateBasePath)(basePath, ui5ConfigPath);
42
+ const fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
43
+ const ui5Conf = await ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
44
+ const preview = ui5Conf.findCustomMiddleware('fiori-tools-preview') ??
45
+ ui5Conf.findCustomMiddleware('preview-middleware');
46
+ await (0, preview_middleware_1.generatePreviewFiles)(basePath, preview?.configuration ?? {}, fs, logger);
47
+ if (!simulate) {
48
+ await new Promise((resolve) => fs.commit(resolve));
63
49
  }
64
- catch (error) {
65
- logger.error(`Error while executing add html '${error.message}'`);
66
- logger.debug(error);
50
+ else {
51
+ await (0, tracing_1.traceChanges)(fs);
67
52
  }
68
- });
53
+ }
54
+ catch (error) {
55
+ logger.error(`Error while executing add html '${error.message}'`);
56
+ logger.debug(error);
57
+ }
69
58
  }
70
59
  //# sourceMappingURL=html.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addAddMockserverConfigCommand = void 0;
13
4
  const path_1 = require("path");
@@ -28,12 +19,12 @@ function addAddMockserverConfigCommand(cmd) {
28
19
  .option('-n, --skip-install', 'skip npm install step')
29
20
  .option('-s, --simulate', 'simulate only do not write or install; sets also --verbose')
30
21
  .option('-v, --verbose', 'show verbose information')
31
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
22
+ .action(async (path, options) => {
32
23
  if (options.verbose === true || options.simulate) {
33
24
  (0, tracing_1.setLogLevelVerbose)();
34
25
  }
35
- yield addMockserverConfig(path || process.cwd(), !!options.simulate, !!options.skipInstall, !!options.interactive);
36
- }));
26
+ await addMockserverConfig(path || process.cwd(), !!options.simulate, !!options.skipInstall, !!options.interactive);
27
+ });
37
28
  }
38
29
  exports.addAddMockserverConfigCommand = addAddMockserverConfigCommand;
39
30
  /**
@@ -44,42 +35,40 @@ exports.addAddMockserverConfigCommand = addAddMockserverConfigCommand;
44
35
  * @param skipInstall - if true, skip execution of npm install
45
36
  * @param interactive - if true, prompt user for config options, otherwise use defaults
46
37
  */
47
- function addMockserverConfig(basePath, simulate, skipInstall, interactive) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const logger = (0, tracing_1.getLogger)();
50
- try {
51
- logger.debug(`Called add mockserver-config for path '${basePath}', simulate is '${simulate}', skip install is '${skipInstall}'`);
52
- yield (0, validation_1.validateBasePath)(basePath);
53
- const webappPath = yield (0, project_access_1.getWebappPath)(basePath);
54
- const config = { webappPath };
55
- if (interactive) {
56
- const questions = (0, mockserver_config_writer_1.getMockserverConfigQuestions)({ webappPath });
57
- config.ui5MockYamlConfig = yield (0, prompts_1.prompt)(questions);
58
- }
59
- const fs = yield (0, mockserver_config_writer_1.generateMockserverConfig)(basePath, config);
60
- yield (0, tracing_1.traceChanges)(fs);
61
- if (!simulate) {
62
- fs.commit(() => {
63
- logger.info(`Changes written.`);
64
- if (skipInstall) {
65
- logger.warn('To finish mockserver configuration run commands:');
66
- const relPath = (0, path_1.relative)(basePath, process.cwd());
67
- if (relPath) {
68
- logger.info(`cd ${relPath}`);
69
- }
70
- logger.info('npm install -D @sap-ux/ui5-middleware-fe-mockserver');
71
- }
72
- else {
73
- logger.debug('Running npm install command');
74
- (0, common_1.runNpmInstallCommand)(basePath, ['--save-dev', '@sap-ux/ui5-middleware-fe-mockserver']);
75
- }
76
- });
77
- }
38
+ async function addMockserverConfig(basePath, simulate, skipInstall, interactive) {
39
+ const logger = (0, tracing_1.getLogger)();
40
+ try {
41
+ logger.debug(`Called add mockserver-config for path '${basePath}', simulate is '${simulate}', skip install is '${skipInstall}'`);
42
+ await (0, validation_1.validateBasePath)(basePath);
43
+ const webappPath = await (0, project_access_1.getWebappPath)(basePath);
44
+ const config = { webappPath };
45
+ if (interactive) {
46
+ const questions = (0, mockserver_config_writer_1.getMockserverConfigQuestions)({ webappPath });
47
+ config.ui5MockYamlConfig = await (0, prompts_1.prompt)(questions);
78
48
  }
79
- catch (error) {
80
- logger.error(`Error while executing add mockserver-config '${error.message}'`);
81
- logger.debug(error);
49
+ const fs = await (0, mockserver_config_writer_1.generateMockserverConfig)(basePath, config);
50
+ await (0, tracing_1.traceChanges)(fs);
51
+ if (!simulate) {
52
+ fs.commit(() => {
53
+ logger.info(`Changes written.`);
54
+ if (skipInstall) {
55
+ logger.warn('To finish mockserver configuration run commands:');
56
+ const relPath = (0, path_1.relative)(basePath, process.cwd());
57
+ if (relPath) {
58
+ logger.info(`cd ${relPath}`);
59
+ }
60
+ logger.info('npm install -D @sap-ux/ui5-middleware-fe-mockserver');
61
+ }
62
+ else {
63
+ logger.debug('Running npm install command');
64
+ (0, common_1.runNpmInstallCommand)(basePath, ['--save-dev', '@sap-ux/ui5-middleware-fe-mockserver']);
65
+ }
66
+ });
82
67
  }
83
- });
68
+ }
69
+ catch (error) {
70
+ logger.error(`Error while executing add mockserver-config '${error.message}'`);
71
+ logger.debug(error);
72
+ }
84
73
  }
85
74
  //# sourceMappingURL=mockserver-config.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addInboundNavigationConfigCommand = void 0;
13
4
  const app_config_writer_1 = require("@sap-ux/app-config-writer");
@@ -22,12 +13,12 @@ function addInboundNavigationConfigCommand(cmd) {
22
13
  cmd.command('inbound-navigation [path]')
23
14
  .option('-s, --simulate', 'simulate only do not write config; sets also --verbose')
24
15
  .option('-v, --verbose', 'show verbose information')
25
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
16
+ .action(async (path, options) => {
26
17
  if (options.verbose === true || options.simulate) {
27
18
  (0, tracing_1.setLogLevelVerbose)();
28
19
  }
29
- yield addInboundNavigationConfig(path || process.cwd(), !!options.simulate);
30
- }));
20
+ await addInboundNavigationConfig(path || process.cwd(), !!options.simulate);
21
+ });
31
22
  }
32
23
  exports.addInboundNavigationConfigCommand = addInboundNavigationConfigCommand;
33
24
  /**
@@ -36,25 +27,23 @@ exports.addInboundNavigationConfigCommand = addInboundNavigationConfigCommand;
36
27
  * @param basePath - path to application root
37
28
  * @param simulate - if true, do not write but just show what would be change; otherwise write
38
29
  */
39
- function addInboundNavigationConfig(basePath, simulate) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const logger = (0, tracing_1.getLogger)();
42
- try {
43
- logger.debug(`Called add inbound navigation-config for path '${basePath}', simulate is '${simulate}'`);
44
- yield (0, validation_1.validateBasePath)(basePath);
45
- const { config, fs } = yield (0, app_config_writer_1.promptInboundNavigationConfig)(basePath);
46
- if (config) {
47
- yield (0, app_config_writer_1.generateInboundNavigationConfig)(basePath, config, true, fs);
48
- }
49
- yield (0, tracing_1.traceChanges)(fs);
50
- if (!simulate) {
51
- fs.commit(() => logger.info(`Inbound navigation configuration complete.`));
52
- }
30
+ async function addInboundNavigationConfig(basePath, simulate) {
31
+ const logger = (0, tracing_1.getLogger)();
32
+ try {
33
+ logger.debug(`Called add inbound navigation-config for path '${basePath}', simulate is '${simulate}'`);
34
+ await (0, validation_1.validateBasePath)(basePath);
35
+ const { config, fs } = await (0, app_config_writer_1.promptInboundNavigationConfig)(basePath);
36
+ if (config) {
37
+ await (0, app_config_writer_1.generateInboundNavigationConfig)(basePath, config, true, fs);
53
38
  }
54
- catch (error) {
55
- logger.error(`Error while executing add inbound navigation configuration '${error.message}'`);
56
- logger.debug(error);
39
+ await (0, tracing_1.traceChanges)(fs);
40
+ if (!simulate) {
41
+ fs.commit(() => logger.info(`Inbound navigation configuration complete.`));
57
42
  }
58
- });
43
+ }
44
+ catch (error) {
45
+ logger.error(`Error while executing add inbound navigation configuration '${error.message}'`);
46
+ logger.debug(error);
47
+ }
59
48
  }
60
49
  //# sourceMappingURL=navigation-config.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addAddSmartLinksConfigCommand = void 0;
13
4
  const app_config_writer_1 = require("@sap-ux/app-config-writer");
@@ -22,12 +13,12 @@ function addAddSmartLinksConfigCommand(cmd) {
22
13
  cmd.command('smartlinks-config [path]')
23
14
  .option('-s, --simulate', 'simulate only do not write config; sets also --verbose')
24
15
  .option('-v, --verbose', 'show verbose information')
25
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
16
+ .action(async (path, options) => {
26
17
  if (options.verbose === true || options.simulate) {
27
18
  (0, tracing_1.setLogLevelVerbose)();
28
19
  }
29
- yield addSmartLinksConfig(path || process.cwd(), !!options.simulate);
30
- }));
20
+ await addSmartLinksConfig(path || process.cwd(), !!options.simulate);
21
+ });
31
22
  }
32
23
  exports.addAddSmartLinksConfigCommand = addAddSmartLinksConfigCommand;
33
24
  /**
@@ -36,23 +27,21 @@ exports.addAddSmartLinksConfigCommand = addAddSmartLinksConfigCommand;
36
27
  * @param basePath - path to application root
37
28
  * @param simulate - if true, do not write but just show what would be change; otherwise write
38
29
  */
39
- function addSmartLinksConfig(basePath, simulate) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const logger = (0, tracing_1.getLogger)();
42
- try {
43
- logger.debug(`Called add smartlinks-config for path '${basePath}', simulate is '${simulate}'`);
44
- yield (0, validation_1.validateBasePath)(basePath);
45
- const config = yield (0, app_config_writer_1.getSmartLinksTargetFromPrompt)(basePath, logger);
46
- const fs = yield (0, app_config_writer_1.generateSmartLinksConfig)(basePath, config, logger);
47
- yield (0, tracing_1.traceChanges)(fs);
48
- if (!simulate) {
49
- fs.commit(() => logger.info(`SmartLinks configuration written.`));
50
- }
30
+ async function addSmartLinksConfig(basePath, simulate) {
31
+ const logger = (0, tracing_1.getLogger)();
32
+ try {
33
+ logger.debug(`Called add smartlinks-config for path '${basePath}', simulate is '${simulate}'`);
34
+ await (0, validation_1.validateBasePath)(basePath);
35
+ const config = await (0, app_config_writer_1.getSmartLinksTargetFromPrompt)(basePath, logger);
36
+ const fs = await (0, app_config_writer_1.generateSmartLinksConfig)(basePath, config, logger);
37
+ await (0, tracing_1.traceChanges)(fs);
38
+ if (!simulate) {
39
+ fs.commit(() => logger.info(`SmartLinks configuration written.`));
51
40
  }
52
- catch (error) {
53
- logger.error(`Error while executing add smartlinks-config '${error.message}'`);
54
- logger.debug(error);
55
- }
56
- });
41
+ }
42
+ catch (error) {
43
+ logger.error(`Error while executing add smartlinks-config '${error.message}'`);
44
+ logger.debug(error);
45
+ }
57
46
  }
58
47
  //# sourceMappingURL=smartlinks-config.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addChangeDataSourceCommand = void 0;
13
4
  const adp_tooling_1 = require("@sap-ux/adp-tooling");
@@ -27,9 +18,9 @@ function addChangeDataSourceCommand(cmd) {
27
18
  cmd.command('data-source [path]')
28
19
  .option('-s, --simulate', 'simulate only do not write or install')
29
20
  .option('-c, --config <string>', 'Path to project configuration file in YAML format', 'ui5.yaml')
30
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
31
- yield changeDataSource(path, Object.assign({}, options), !!options.simulate, options.config);
32
- }));
21
+ .action(async (path, options) => {
22
+ await changeDataSource(path, { ...options }, !!options.simulate, options.config);
23
+ });
33
24
  }
34
25
  exports.addChangeDataSourceCommand = addChangeDataSourceCommand;
35
26
  /**
@@ -40,55 +31,53 @@ exports.addChangeDataSourceCommand = addChangeDataSourceCommand;
40
31
  * @param {boolean} simulate - If set to true, then no files will be written to the filesystem.
41
32
  * @param {string} yamlPath - The path to the project configuration file in YAML format.
42
33
  */
43
- function changeDataSource(basePath, defaults, simulate, yamlPath) {
44
- var _a, _b, _c;
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const logger = (0, tracing_1.getLogger)();
47
- try {
48
- if (!basePath) {
49
- basePath = process.cwd();
50
- }
51
- if ((yield (0, project_access_1.getAppType)(basePath)) !== 'Fiori Adaptation') {
52
- throw new Error('This command can only be used for an Adaptation Project');
53
- }
54
- checkEnvironment(basePath);
55
- const variant = getVariant(basePath);
56
- const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
57
- const ui5Conf = yield ui5_config_1.UI5Config.newInstance((0, fs_1.readFileSync)(ui5ConfigPath, 'utf-8'));
58
- const customMiddlerware = (_a = ui5Conf.findCustomMiddleware('fiori-tools-preview')) !== null && _a !== void 0 ? _a : ui5Conf.findCustomMiddleware('preview-middleware');
59
- const adp = (_b = customMiddlerware === null || customMiddlerware === void 0 ? void 0 : customMiddlerware.configuration) === null || _b === void 0 ? void 0 : _b.adp;
60
- if (!adp) {
61
- throw new Error('No system configuration found in ui5.yaml');
62
- }
63
- const manifest = yield (0, adp_tooling_1.getManifest)(variant.reference, adp, logger);
64
- const dataSources = manifest['sap.app'].dataSources;
65
- if (!dataSources) {
66
- throw new Error('No data sources found in the manifest');
67
- }
68
- const answers = yield (0, common_1.promptYUIQuestions)((0, adp_tooling_1.getPromptsForChangeDataSource)(dataSources), false);
69
- const fs = yield (0, adp_tooling_1.generateChange)(basePath, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, {
70
- variant,
71
- dataSources,
72
- answers
73
- });
74
- if (!simulate) {
75
- yield new Promise((resolve) => fs.commit(resolve));
76
- }
77
- else {
78
- yield (0, tracing_1.traceChanges)(fs);
79
- }
34
+ async function changeDataSource(basePath, defaults, simulate, yamlPath) {
35
+ const logger = (0, tracing_1.getLogger)();
36
+ try {
37
+ if (!basePath) {
38
+ basePath = process.cwd();
80
39
  }
81
- catch (error) {
82
- logger.error(error.message);
83
- if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 401 && loginAttempts) {
84
- loginAttempts--;
85
- logger.error(`Authentication failed. Please check your credentials. Login attempts left: ${loginAttempts}`);
86
- yield changeDataSource(basePath, defaults, simulate, yamlPath);
87
- return;
88
- }
89
- logger.debug(error);
40
+ if ((await (0, project_access_1.getAppType)(basePath)) !== 'Fiori Adaptation') {
41
+ throw new Error('This command can only be used for an Adaptation Project');
90
42
  }
91
- });
43
+ checkEnvironment(basePath);
44
+ const variant = getVariant(basePath);
45
+ const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
46
+ const ui5Conf = await ui5_config_1.UI5Config.newInstance((0, fs_1.readFileSync)(ui5ConfigPath, 'utf-8'));
47
+ const customMiddlerware = ui5Conf.findCustomMiddleware('fiori-tools-preview') ??
48
+ ui5Conf.findCustomMiddleware('preview-middleware');
49
+ const adp = customMiddlerware?.configuration?.adp;
50
+ if (!adp) {
51
+ throw new Error('No system configuration found in ui5.yaml');
52
+ }
53
+ const manifest = await (0, adp_tooling_1.getManifest)(variant.reference, adp, logger);
54
+ const dataSources = manifest['sap.app'].dataSources;
55
+ if (!dataSources) {
56
+ throw new Error('No data sources found in the manifest');
57
+ }
58
+ const answers = await (0, common_1.promptYUIQuestions)((0, adp_tooling_1.getPromptsForChangeDataSource)(dataSources), false);
59
+ const fs = await (0, adp_tooling_1.generateChange)(basePath, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, {
60
+ variant,
61
+ dataSources,
62
+ answers
63
+ });
64
+ if (!simulate) {
65
+ await new Promise((resolve) => fs.commit(resolve));
66
+ }
67
+ else {
68
+ await (0, tracing_1.traceChanges)(fs);
69
+ }
70
+ }
71
+ catch (error) {
72
+ logger.error(error.message);
73
+ if (error.response?.status === 401 && loginAttempts) {
74
+ loginAttempts--;
75
+ logger.error(`Authentication failed. Please check your credentials. Login attempts left: ${loginAttempts}`);
76
+ await changeDataSource(basePath, defaults, simulate, yamlPath);
77
+ return;
78
+ }
79
+ logger.debug(error);
80
+ }
92
81
  }
93
82
  /**
94
83
  * Get the app descriptor variant.
@@ -1,13 +1,4 @@
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
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -35,11 +26,11 @@ function addGenerateAdaptationProjectCommand(cmd) {
35
26
  .option('--ft', 'enable the Fiori tools for the generated project')
36
27
  .option('--package [package]', 'ABAP package to be used for deployments')
37
28
  .option('--transport [transport]', 'ABAP transport to be used for deployments')
38
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
29
+ .action(async (path, options) => {
39
30
  console.log(`\nThe generation of adaptation projects outside of SAP Business Application Studio is currently ${chalk_1.default.bold('experimental')}.`);
40
31
  console.log('Please report any issues or feedback at https://github.com/SAP/open-ux-tools/issues/new/choose.\n');
41
- yield generateAdaptationProject(path, Object.assign({}, options), !!options.yes, !!options.simulate, !!options.skipInstall);
42
- }));
32
+ await generateAdaptationProject(path, { ...options }, !!options.yes, !!options.simulate, !!options.skipInstall);
33
+ });
43
34
  }
44
35
  exports.addGenerateAdaptationProjectCommand = addGenerateAdaptationProjectCommand;
45
36
  /**
@@ -51,38 +42,35 @@ exports.addGenerateAdaptationProjectCommand = addGenerateAdaptationProjectComman
51
42
  * @param simulate if set to true, then no files will be written to the filesystem
52
43
  * @param skipInstall if set to true then `npm i` is not executed in the new project
53
44
  */
54
- function generateAdaptationProject(basePath, defaults, useDefaults, simulate, skipInstall) {
55
- var _a;
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const logger = (0, tracing_1.getLogger)();
58
- try {
59
- logger.debug(`Called generate adaptation-project for path '${basePath}', skip install is '${skipInstall}'`);
60
- if (defaults.url) {
61
- const url = new URL(defaults.url);
62
- defaults.url = url.origin;
63
- defaults.client = (_a = url.searchParams.get('sap-client')) !== null && _a !== void 0 ? _a : undefined;
64
- }
65
- const config = useDefaults ? createConfigFromDefaults(defaults) : yield (0, adp_tooling_1.promptGeneratorInput)(defaults, logger);
66
- if (!basePath) {
67
- basePath = (0, path_1.join)(process.cwd(), config.app.id);
68
- }
69
- addChangeForResourceModel(config);
70
- const fs = yield (0, adp_tooling_1.generate)(basePath, config);
71
- if (!simulate) {
72
- yield new Promise((resolve) => fs.commit(resolve));
73
- if (!skipInstall) {
74
- (0, common_1.runNpmInstallCommand)(basePath);
75
- logger.info('Executed npm install');
76
- }
77
- }
78
- else {
79
- yield (0, tracing_1.traceChanges)(fs);
45
+ async function generateAdaptationProject(basePath, defaults, useDefaults, simulate, skipInstall) {
46
+ const logger = (0, tracing_1.getLogger)();
47
+ try {
48
+ logger.debug(`Called generate adaptation-project for path '${basePath}', skip install is '${skipInstall}'`);
49
+ if (defaults.url) {
50
+ const url = new URL(defaults.url);
51
+ defaults.url = url.origin;
52
+ defaults.client = url.searchParams.get('sap-client') ?? undefined;
53
+ }
54
+ const config = useDefaults ? createConfigFromDefaults(defaults) : await (0, adp_tooling_1.promptGeneratorInput)(defaults, logger);
55
+ if (!basePath) {
56
+ basePath = (0, path_1.join)(process.cwd(), config.app.id);
57
+ }
58
+ addChangeForResourceModel(config);
59
+ const fs = await (0, adp_tooling_1.generate)(basePath, config);
60
+ if (!simulate) {
61
+ await new Promise((resolve) => fs.commit(resolve));
62
+ if (!skipInstall) {
63
+ (0, common_1.runNpmInstallCommand)(basePath);
64
+ logger.info('Executed npm install');
80
65
  }
81
66
  }
82
- catch (error) {
83
- logger.error(error.message);
67
+ else {
68
+ await (0, tracing_1.traceChanges)(fs);
84
69
  }
85
- });
70
+ }
71
+ catch (error) {
72
+ logger.error(error.message);
73
+ }
86
74
  }
87
75
  /**
88
76
  * Create a writer config based on the given defaults.
@@ -1,13 +1,4 @@
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
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -26,12 +17,12 @@ function addRemoveMockserverConfigCommand(cmd) {
26
17
  cmd.command('mockserver-config [path]')
27
18
  .option('-v, --verbose', 'show verbose information')
28
19
  .option('-f, --force', 'do not ask for confirmation when deleting files')
29
- .action((path, options) => __awaiter(this, void 0, void 0, function* () {
20
+ .action(async (path, options) => {
30
21
  if (options.verbose === true) {
31
22
  (0, tracing_1.setLogLevelVerbose)();
32
23
  }
33
- yield removeMockserverConfiguration(path || process.cwd(), !!options.force);
34
- }));
24
+ await removeMockserverConfiguration(path || process.cwd(), !!options.force);
25
+ });
35
26
  }
36
27
  exports.addRemoveMockserverConfigCommand = addRemoveMockserverConfigCommand;
37
28
  /**
@@ -40,35 +31,33 @@ exports.addRemoveMockserverConfigCommand = addRemoveMockserverConfigCommand;
40
31
  * @param basePath - path to application root
41
32
  * @param force - if true, do not ask before deleting files; otherwise ask
42
33
  */
43
- function removeMockserverConfiguration(basePath, force) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const logger = (0, tracing_1.getLogger)();
46
- try {
47
- logger.debug(`Called remove mockserver-config for path '${basePath}', force is '${force}'`);
48
- yield (0, validation_1.validateBasePath)(basePath);
49
- const fs = (0, mockserver_config_writer_1.removeMockserverConfig)(basePath);
50
- yield (0, tracing_1.traceChanges)(fs);
51
- const hasDeletions = (0, validation_1.hasFileDeletes)(fs);
52
- let doCommit = true;
53
- if (hasDeletions && !force) {
54
- doCommit = (yield (0, prompts_1.default)([
55
- {
56
- type: 'confirm',
57
- name: 'doCommit',
58
- message: `Do you want to apply the changes?`
59
- }
60
- ])).doCommit;
61
- }
62
- if (doCommit) {
63
- fs.commit(() => {
64
- logger.info(`Mockserver config removed`);
65
- });
66
- }
34
+ async function removeMockserverConfiguration(basePath, force) {
35
+ const logger = (0, tracing_1.getLogger)();
36
+ try {
37
+ logger.debug(`Called remove mockserver-config for path '${basePath}', force is '${force}'`);
38
+ await (0, validation_1.validateBasePath)(basePath);
39
+ const fs = (0, mockserver_config_writer_1.removeMockserverConfig)(basePath);
40
+ await (0, tracing_1.traceChanges)(fs);
41
+ const hasDeletions = (0, validation_1.hasFileDeletes)(fs);
42
+ let doCommit = true;
43
+ if (hasDeletions && !force) {
44
+ doCommit = (await (0, prompts_1.default)([
45
+ {
46
+ type: 'confirm',
47
+ name: 'doCommit',
48
+ message: `Do you want to apply the changes?`
49
+ }
50
+ ])).doCommit;
67
51
  }
68
- catch (error) {
69
- logger.error(`Error while executing remove mockserver-config '${error.message}'`);
70
- logger.debug(error);
52
+ if (doCommit) {
53
+ fs.commit(() => {
54
+ logger.info(`Mockserver config removed`);
55
+ });
71
56
  }
72
- });
57
+ }
58
+ catch (error) {
59
+ logger.error(`Error while executing remove mockserver-config '${error.message}'`);
60
+ logger.debug(error);
61
+ }
73
62
  }
74
63
  //# sourceMappingURL=mockserver-config.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -36,19 +27,17 @@ const QUESTION_TYPE_MAP = {
36
27
  * @param prompt converted prompt
37
28
  * @param answers previously given answers
38
29
  */
39
- function enhanceListQuestion(listQuestion, prompt, answers) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const choices = (isFunction(listQuestion.choices) ? yield listQuestion.choices(answers) : listQuestion.choices);
42
- const mapppedChoices = choices.map((choice) => ({
43
- title: typeof choice === 'object' ? choice.name : `${choice}`,
44
- value: typeof choice === 'object' ? choice.value : choice
45
- }));
46
- const initialValue = prompt.initial();
47
- prompt.choices = mapppedChoices;
48
- prompt.initial = () => mapppedChoices[initialValue]
49
- ? initialValue
50
- : mapppedChoices.findIndex((choice) => choice.value === initialValue);
51
- });
30
+ async function enhanceListQuestion(listQuestion, prompt, answers) {
31
+ const choices = (isFunction(listQuestion.choices) ? await listQuestion.choices(answers) : listQuestion.choices);
32
+ const mapppedChoices = choices.map((choice) => ({
33
+ title: typeof choice === 'object' ? choice.name : `${choice}`,
34
+ value: typeof choice === 'object' ? choice.value : choice
35
+ }));
36
+ const initialValue = prompt.initial();
37
+ prompt.choices = mapppedChoices;
38
+ prompt.initial = () => mapppedChoices[initialValue]
39
+ ? initialValue
40
+ : mapppedChoices.findIndex((choice) => choice.value === initialValue);
52
41
  }
53
42
  /**
54
43
  * Indicates if the question is optional.
@@ -57,16 +46,14 @@ function enhanceListQuestion(listQuestion, prompt, answers) {
57
46
  * @param answers rpeviously given answers
58
47
  * @returns message of the question
59
48
  */
60
- function extractMessage(question, answers) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const message = isFunction(question.message) ? yield question.message(answers) : question.message;
63
- if (question.guiOptions && !question.guiOptions.mandatory) {
64
- return `${message} (optional)`;
65
- }
66
- else {
67
- return message;
68
- }
69
- });
49
+ async function extractMessage(question, answers) {
50
+ const message = isFunction(question.message) ? await question.message(answers) : question.message;
51
+ if (question.guiOptions && !question.guiOptions.mandatory) {
52
+ return `${message} (optional)`;
53
+ }
54
+ else {
55
+ return message;
56
+ }
70
57
  }
71
58
  /**
72
59
  * Converts a YUI question to a simple prompts question.
@@ -75,21 +62,18 @@ function extractMessage(question, answers) {
75
62
  * @param answers previously given answers
76
63
  * @returns question converted to prompts question
77
64
  */
78
- function convertQuestion(question, answers) {
79
- var _a, _b;
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const prompt = {
82
- type: (_b = QUESTION_TYPE_MAP[(_a = question.type) !== null && _a !== void 0 ? _a : 'input']) !== null && _b !== void 0 ? _b : question.type,
83
- name: question.name,
84
- message: yield extractMessage(question, answers),
85
- validate: (value) => __awaiter(this, void 0, void 0, function* () { var _c; return isFunction(question.validate) ? yield question.validate(value, answers) : (_c = question.validate) !== null && _c !== void 0 ? _c : true; }),
86
- initial: () => (isFunction(question.default) ? question.default(answers) : question.default)
87
- };
88
- if (question.choices) {
89
- yield enhanceListQuestion(question, prompt, answers);
90
- }
91
- return prompt;
92
- });
65
+ async function convertQuestion(question, answers) {
66
+ const prompt = {
67
+ type: QUESTION_TYPE_MAP[question.type ?? 'input'] ?? question.type,
68
+ name: question.name,
69
+ message: await extractMessage(question, answers),
70
+ validate: async (value) => isFunction(question.validate) ? await question.validate(value, answers) : question.validate ?? true,
71
+ initial: () => (isFunction(question.default) ? question.default(answers) : question.default)
72
+ };
73
+ if (question.choices) {
74
+ await enhanceListQuestion(question, prompt, answers);
75
+ }
76
+ return prompt;
93
77
  }
94
78
  exports.convertQuestion = convertQuestion;
95
79
  /**
@@ -99,21 +83,19 @@ exports.convertQuestion = convertQuestion;
99
83
  * @param useDefaults - if true, the default values are used for all prompts
100
84
  * @returns the answers to the questions
101
85
  */
102
- function promptYUIQuestions(questions, useDefaults) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const answers = {};
105
- for (const question of questions) {
106
- if (isFunction(question.when) ? question.when(answers) : question.when !== false) {
107
- if (useDefaults) {
108
- answers[question.name] = isFunction(question.default) ? question.default(answers) : question.default;
109
- }
110
- else {
111
- answers[question.name] = yield promptSingleQuestion(answers, question);
112
- }
86
+ async function promptYUIQuestions(questions, useDefaults) {
87
+ const answers = {};
88
+ for (const question of questions) {
89
+ if (isFunction(question.when) ? question.when(answers) : question.when !== false) {
90
+ if (useDefaults) {
91
+ answers[question.name] = isFunction(question.default) ? question.default(answers) : question.default;
92
+ }
93
+ else {
94
+ answers[question.name] = await promptSingleQuestion(answers, question);
113
95
  }
114
96
  }
115
- return answers;
116
- });
97
+ }
98
+ return answers;
117
99
  }
118
100
  exports.promptYUIQuestions = promptYUIQuestions;
119
101
  /**
@@ -123,23 +105,21 @@ exports.promptYUIQuestions = promptYUIQuestions;
123
105
  * @param question question to be prompted
124
106
  * @returns a promise with the answer of the question
125
107
  */
126
- function promptSingleQuestion(answers, question) {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- const q = yield convertQuestion(question, answers);
129
- const answer = yield (0, prompts_1.default)(q, {
130
- onCancel: () => {
131
- throw new Error('User canceled the prompt');
132
- }
133
- });
134
- // prompts does not handle validation for autocomplete out of the box
135
- if (q.type === 'autocomplete') {
136
- const valid = yield q.validate(answer[question.name]);
137
- if (valid !== true) {
138
- (0, tracing_1.getLogger)().warn(valid);
139
- return promptSingleQuestion(answers, question);
140
- }
108
+ async function promptSingleQuestion(answers, question) {
109
+ const q = await convertQuestion(question, answers);
110
+ const answer = await (0, prompts_1.default)(q, {
111
+ onCancel: () => {
112
+ throw new Error('User canceled the prompt');
141
113
  }
142
- return answer[question.name];
143
114
  });
115
+ // prompts does not handle validation for autocomplete out of the box
116
+ if (q.type === 'autocomplete') {
117
+ const valid = await q.validate(answer[question.name]);
118
+ if (valid !== true) {
119
+ (0, tracing_1.getLogger)().warn(valid);
120
+ return promptSingleQuestion(answers, question);
121
+ }
122
+ }
123
+ return answer[question.name];
144
124
  }
145
125
  //# sourceMappingURL=prompts.js.map
@@ -32,17 +32,16 @@ exports.getLogger = getLogger;
32
32
  * @param logger - instance of the logger
33
33
  */
34
34
  function setCustomFormatter(logger) {
35
- var _a;
36
- const transports = (_a = logger === null || logger === void 0 ? void 0 : logger._logger) === null || _a === void 0 ? void 0 : _a.transports;
35
+ const transports = logger?._logger?.transports;
37
36
  if (!Array.isArray(transports)) {
38
37
  return;
39
38
  }
40
- const consoleTransport = transports.find((t) => (t === null || t === void 0 ? void 0 : t.name) === 'console');
41
- if (consoleTransport === null || consoleTransport === void 0 ? void 0 : consoleTransport.format) {
39
+ const consoleTransport = transports.find((t) => t?.name === 'console');
40
+ if (consoleTransport?.format) {
42
41
  consoleTransport.format.transform = (info) => {
43
42
  const colorFn = levelColor[info.level] ? chalk_1.default.keyword(levelColor[info.level]) : (m) => m;
44
43
  const formattedMessage = colorFn ? colorFn(info.message) : info.message;
45
- const symbol = Object.getOwnPropertySymbols(info).find((s) => (s === null || s === void 0 ? void 0 : s.description) === 'message');
44
+ const symbol = Object.getOwnPropertySymbols(info).find((s) => s?.description === 'message');
46
45
  if (symbol) {
47
46
  info[symbol] = formattedMessage;
48
47
  }
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.traceChanges = void 0;
13
4
  const fs_1 = require("fs");
@@ -19,44 +10,42 @@ const logger_1 = require("./logger");
19
10
  *
20
11
  * @param fs - mem-fs-editor
21
12
  */
22
- function traceChanges(fs) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const changedFiles = fs.dump() || {};
25
- const logger = (0, logger_1.getLogger)();
26
- for (const changedFile in changedFiles) {
27
- const fileStat = changedFiles[changedFile];
28
- if (fileStat.state === 'deleted') {
29
- logger.info(`File '${changedFile}' ${fileStat.state}`);
30
- continue;
31
- }
32
- const memContent = fileStat.contents;
33
- if (!(0, fs_1.existsSync)(changedFile)) {
34
- logger.info(`File '${changedFile}' added`);
35
- logger.debug(`File content:\n${memContent}`);
36
- continue;
37
- }
38
- const discContent = yield fs_1.promises.readFile(changedFile, 'utf-8');
39
- if (discContent === memContent) {
40
- logger.info(`File '${changedFile}' unchanged`);
41
- logger.debug(`File content:\n${memContent}`);
42
- continue;
13
+ async function traceChanges(fs) {
14
+ const changedFiles = fs.dump() || {};
15
+ const logger = (0, logger_1.getLogger)();
16
+ for (const changedFile in changedFiles) {
17
+ const fileStat = changedFiles[changedFile];
18
+ if (fileStat.state === 'deleted') {
19
+ logger.info(`File '${changedFile}' ${fileStat.state}`);
20
+ continue;
21
+ }
22
+ const memContent = fileStat.contents;
23
+ if (!(0, fs_1.existsSync)(changedFile)) {
24
+ logger.info(`File '${changedFile}' added`);
25
+ logger.debug(`File content:\n${memContent}`);
26
+ continue;
27
+ }
28
+ const discContent = await fs_1.promises.readFile(changedFile, 'utf-8');
29
+ if (discContent === memContent) {
30
+ logger.info(`File '${changedFile}' unchanged`);
31
+ logger.debug(`File content:\n${memContent}`);
32
+ continue;
33
+ }
34
+ logger.info(`File '${changedFile}' modified`);
35
+ const fileExtension = (0, path_1.extname)(changedFile).toLowerCase();
36
+ switch (fileExtension) {
37
+ case '.json': {
38
+ (0, compare_1.compareJson)(JSON.parse(discContent), JSON.parse(memContent));
39
+ break;
43
40
  }
44
- logger.info(`File '${changedFile}' modified`);
45
- const fileExtension = (0, path_1.extname)(changedFile).toLowerCase();
46
- switch (fileExtension) {
47
- case '.json': {
48
- (0, compare_1.compareJson)(JSON.parse(discContent), JSON.parse(memContent));
49
- break;
50
- }
51
- case '.yaml': {
52
- (0, compare_1.compareStrings)(discContent, memContent);
53
- break;
54
- }
55
- default:
56
- logger.debug(`Can't compare file. New file content:\n${memContent}`);
41
+ case '.yaml': {
42
+ (0, compare_1.compareStrings)(discContent, memContent);
43
+ break;
57
44
  }
45
+ default:
46
+ logger.debug(`Can't compare file. New file content:\n${memContent}`);
58
47
  }
59
- });
48
+ }
60
49
  }
61
50
  exports.traceChanges = traceChanges;
62
51
  //# sourceMappingURL=trace.js.map
@@ -1,13 +1,4 @@
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
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.hasFileDeletes = exports.validateBasePath = void 0;
13
4
  const project_access_1 = require("@sap-ux/project-access");
@@ -19,18 +10,16 @@ const path_1 = require("path");
19
10
  * @param basePath - base path of the app, where package.json and ui5.yaml resides
20
11
  * @param ui5YamlPath - optional path to ui5.yaml file
21
12
  */
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
- });
13
+ async function validateBasePath(basePath, ui5YamlPath) {
14
+ const packageJsonPath = (0, path_1.join)(basePath, 'package.json');
15
+ if (!(0, fs_1.existsSync)(packageJsonPath)) {
16
+ throw Error(`Required file '${packageJsonPath}' does not exist.`);
17
+ }
18
+ ui5YamlPath ??= (0, path_1.join)(basePath, 'ui5.yaml');
19
+ const webappPath = await (0, project_access_1.getWebappPath)(basePath);
20
+ if (!(0, fs_1.existsSync)(ui5YamlPath) && !(0, fs_1.existsSync)(webappPath)) {
21
+ throw Error(`There must be either a folder '${webappPath}' or a config file '${ui5YamlPath}'`);
22
+ }
34
23
  }
35
24
  exports.validateBasePath = validateBasePath;
36
25
  /**
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.6.8",
4
+ "version": "0.7.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,17 +30,17 @@
30
30
  "mem-fs": "2.1.0",
31
31
  "mem-fs-editor": "9.4.0",
32
32
  "prompts": "2.4.2",
33
- "@sap-ux/adp-tooling": "0.11.13",
34
- "@sap-ux/app-config-writer": "0.3.84",
35
- "@sap-ux/cap-config-writer": "0.5.7",
36
- "@sap-ux/cards-editor-config-writer": "0.3.9",
37
- "@sap-ux/inquirer-common": "0.3.1",
38
- "@sap-ux/logger": "0.5.1",
39
- "@sap-ux/mockserver-config-writer": "0.5.8",
40
- "@sap-ux/preview-middleware": "0.15.7",
41
- "@sap-ux/project-access": "1.22.4",
42
- "@sap-ux/system-access": "0.4.7",
43
- "@sap-ux/ui5-config": "0.22.10"
33
+ "@sap-ux/adp-tooling": "0.12.1",
34
+ "@sap-ux/app-config-writer": "0.4.1",
35
+ "@sap-ux/cap-config-writer": "0.6.1",
36
+ "@sap-ux/cards-editor-config-writer": "0.4.0",
37
+ "@sap-ux/inquirer-common": "0.4.0",
38
+ "@sap-ux/logger": "0.6.0",
39
+ "@sap-ux/mockserver-config-writer": "0.6.0",
40
+ "@sap-ux/preview-middleware": "0.16.1",
41
+ "@sap-ux/project-access": "1.23.0",
42
+ "@sap-ux/system-access": "0.5.1",
43
+ "@sap-ux/ui5-config": "0.23.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/diff": "5.0.9",
@@ -48,8 +48,8 @@
48
48
  "@types/mem-fs": "1.1.2",
49
49
  "@types/mem-fs-editor": "7.0.1",
50
50
  "@types/prompts": "2.4.4",
51
- "@sap-ux/inquirer-common": "0.3.1",
52
- "@sap-ux/store": "0.6.0"
51
+ "@sap-ux/inquirer-common": "0.4.0",
52
+ "@sap-ux/store": "0.7.0"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "tsc --build",