@sap-ux/create 0.1.13 → 0.2.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.
@@ -0,0 +1,8 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Add the "add cds-plugin-ui5" command to passed command.
4
+ *
5
+ * @param cmd - commander command for adding cds-plugin-ui5 command
6
+ */
7
+ export declare function addAddCdsPluginUi5Command(cmd: Command): void;
8
+ //# sourceMappingURL=cds-plugin-ui.d.ts.map
@@ -0,0 +1,73 @@
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.addAddCdsPluginUi5Command = void 0;
13
+ const path_1 = require("path");
14
+ const cap_config_writer_1 = require("@sap-ux/cap-config-writer");
15
+ const tracing_1 = require("../../tracing");
16
+ const common_1 = require("../../common");
17
+ /**
18
+ * Add the "add cds-plugin-ui5" command to passed command.
19
+ *
20
+ * @param cmd - commander command for adding cds-plugin-ui5 command
21
+ */
22
+ function addAddCdsPluginUi5Command(cmd) {
23
+ cmd.command('cds-plugin-ui5 [path]')
24
+ .option('-n, --skip-install', 'skip npm install step')
25
+ .option('-s, --simulate', 'simulate only, do not write or install; sets also --verbose')
26
+ .option('-v, --verbose', 'show verbose information')
27
+ .action((path, options) => __awaiter(this, void 0, void 0, function* () {
28
+ if (options.verbose === true || options.simulate) {
29
+ (0, tracing_1.setLogLevelVerbose)();
30
+ }
31
+ yield addCdsPluginUi5(path || process.cwd(), !!options.simulate, !!options.skipInstall);
32
+ }));
33
+ }
34
+ exports.addAddCdsPluginUi5Command = addAddCdsPluginUi5Command;
35
+ /**
36
+ * Add cds-plugin-ui5 and all prerequisites to a CAP project.
37
+ *
38
+ * @param basePath - CAP project root
39
+ * @param simulate - if true, do not write but just show what would be change; otherwise write
40
+ * @param skipInstall - if true, skip execution of npm install
41
+ */
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);
63
+ }
64
+ });
65
+ }
66
+ }
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
+ });
72
+ }
73
+ //# sourceMappingURL=cds-plugin-ui.js.map
@@ -4,6 +4,7 @@ exports.getAddCommands = void 0;
4
4
  const commander_1 = require("commander");
5
5
  const mockserver_config_1 = require("./mockserver-config");
6
6
  const smartlinks_config_1 = require("./smartlinks-config");
7
+ const cds_plugin_ui_1 = require("./cds-plugin-ui");
7
8
  /**
8
9
  * Return 'create-fiori add *' commands. Commands include also the handler action.
9
10
  *
@@ -15,6 +16,8 @@ function getAddCommands() {
15
16
  (0, mockserver_config_1.addAddMockserverConfigCommand)(addCommands);
16
17
  // create-fiori add smartlinks-config
17
18
  (0, smartlinks_config_1.addAddSmartLinksConfigCommand)(addCommands);
19
+ // create-fiori add cds-plugin-ui5
20
+ (0, cds_plugin_ui_1.addAddCdsPluginUi5Command)(addCommands);
18
21
  return addCommands;
19
22
  }
20
23
  exports.getAddCommands = getAddCommands;
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.addAddMockserverConfigCommand = void 0;
13
- const child_process_1 = require("child_process");
13
+ const path_1 = require("path");
14
14
  const prompts_1 = require("prompts");
15
15
  const project_access_1 = require("@sap-ux/project-access");
16
16
  const mockserver_config_writer_1 = require("@sap-ux/mockserver-config-writer");
17
17
  const tracing_1 = require("../../tracing");
18
18
  const validation_1 = require("../../validation");
19
- const path_1 = require("path");
19
+ const common_1 = require("../../common");
20
20
  /**
21
21
  * Add the "add mockserver config" command to a passed command.
22
22
  *
@@ -71,7 +71,7 @@ function addMockserverConfig(basePath, simulate, skipInstall, interactive) {
71
71
  }
72
72
  else {
73
73
  logger.debug('Running npm install command');
74
- runNpmInstall(basePath);
74
+ (0, common_1.runNpmInstallCommand)(basePath, ['--save-dev', '@sap-ux/ui5-middleware-fe-mockserver']);
75
75
  }
76
76
  });
77
77
  }
@@ -82,16 +82,4 @@ function addMockserverConfig(basePath, simulate, skipInstall, interactive) {
82
82
  }
83
83
  });
84
84
  }
85
- /**
86
- * Run npm install for mockserver middleware in the root folder of application.
87
- *
88
- * @param basePath - path to application root
89
- */
90
- function runNpmInstall(basePath) {
91
- const npmCommand = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
92
- (0, child_process_1.spawnSync)(npmCommand, ['install', '--save-dev', '@sap-ux/ui5-middleware-fe-mockserver'], {
93
- cwd: basePath,
94
- stdio: [0, 1, 2]
95
- });
96
- }
97
85
  //# sourceMappingURL=mockserver-config.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Run npm install command.
3
+ *
4
+ * @param basePath - path to application root
5
+ * @param [installArgs] - optional string array of arguments
6
+ */
7
+ export declare function runNpmInstallCommand(basePath: string, installArgs?: string[]): void;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runNpmInstallCommand = void 0;
4
+ const child_process_1 = require("child_process");
5
+ /**
6
+ * Run npm install command.
7
+ *
8
+ * @param basePath - path to application root
9
+ * @param [installArgs] - optional string array of arguments
10
+ */
11
+ function runNpmInstallCommand(basePath, installArgs = []) {
12
+ const npmCommand = process.platform.startsWith('win') ? 'npm.cmd' : 'npm';
13
+ const args = ['install', ...installArgs];
14
+ (0, child_process_1.spawnSync)(npmCommand, args, {
15
+ cwd: basePath,
16
+ stdio: [0, 1, 2]
17
+ });
18
+ }
19
+ exports.runNpmInstallCommand = runNpmInstallCommand;
20
+ //# sourceMappingURL=index.js.map
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.1.13",
4
+ "version": "0.2.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,10 +29,11 @@
29
29
  "commander": "9.4.0",
30
30
  "diff": "5.1.0",
31
31
  "prompts": "2.4.2",
32
- "@sap-ux/app-config-writer": "0.0.15",
32
+ "@sap-ux/app-config-writer": "0.0.17",
33
+ "@sap-ux/cap-config-writer": "0.0.1",
33
34
  "@sap-ux/logger": "0.3.5",
34
35
  "@sap-ux/mockserver-config-writer": "0.1.3",
35
- "@sap-ux/project-access": "1.7.0"
36
+ "@sap-ux/project-access": "1.8.0"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@types/diff": "5.0.2",