@sap-ux/adp-tooling 0.10.6 → 0.10.8

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/dist/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { UI5FlexLayer } from '@sap-ux/project-access';
2
2
  import type { DestinationAbapTarget, UrlAbapTarget } from '@sap-ux/system-access';
3
3
  import type { Adp } from '@sap-ux/ui5-config';
4
4
  import type { Editor } from 'mem-fs-editor';
5
+ import type { OperationsType } from '@sap-ux/axios-extension';
5
6
  export interface DescriptorVariant {
6
7
  layer: UI5FlexLayer;
7
8
  reference: string;
@@ -30,11 +31,14 @@ export interface AdpWriterConfig {
30
31
  target: AbapTarget;
31
32
  ui5?: {
32
33
  minVersion?: string;
34
+ version?: string;
35
+ frameworkUrl?: string;
33
36
  };
34
37
  package?: {
35
38
  name?: string;
36
39
  description?: string;
37
40
  };
41
+ customConfig?: AdpCustomConfig;
38
42
  /**
39
43
  * Optional: configuration for deployment to ABAP
40
44
  */
@@ -308,5 +312,11 @@ export interface AdpProjectData {
308
312
  reference: string;
309
313
  id: string;
310
314
  }
315
+ export interface AdpCustomConfig {
316
+ adp: {
317
+ safeMode: boolean;
318
+ environment: OperationsType;
319
+ };
320
+ }
311
321
  export {};
312
322
  //# sourceMappingURL=types.d.ts.map
@@ -13,8 +13,7 @@ exports.migrate = exports.generate = void 0;
13
13
  const path_1 = require("path");
14
14
  const mem_fs_1 = require("mem-fs");
15
15
  const mem_fs_editor_1 = require("mem-fs-editor");
16
- const ui5_config_1 = require("@sap-ux/ui5-config");
17
- const options_1 = require("./options");
16
+ const project_utils_1 = require("./project-utils");
18
17
  const tmplPath = (0, path_1.join)(__dirname, '../../templates/project');
19
18
  /**
20
19
  * Set default values for optional properties.
@@ -30,7 +29,8 @@ function setDefaults(config) {
30
29
  target: Object.assign({}, config.target),
31
30
  ui5: Object.assign({}, config.ui5),
32
31
  deploy: config.deploy ? Object.assign({}, config.deploy) : undefined,
33
- options: Object.assign({}, config.options)
32
+ options: Object.assign({}, config.options),
33
+ customConfig: config.customConfig ? Object.assign({}, config.customConfig) : undefined
34
34
  };
35
35
  (_a = (_f = configWithDefaults.app).title) !== null && _a !== void 0 ? _a : (_f.title = `Adaptation of ${config.app.reference}`);
36
36
  (_b = (_g = configWithDefaults.app).layer) !== null && _b !== void 0 ? _b : (_g.layer = 'CUSTOMER_BASE');
@@ -39,22 +39,6 @@ function setDefaults(config) {
39
39
  (_e = (_j = configWithDefaults.package).description) !== null && _e !== void 0 ? _e : (_j.description = configWithDefaults.app.title);
40
40
  return configWithDefaults;
41
41
  }
42
- function writeUi5Yaml(basePath, config, fs) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- // ui5.yaml
45
- const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
46
- const baseUi5ConfigContent = fs.read(ui5ConfigPath);
47
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
48
- (0, options_1.enhanceUI5Yaml)(ui5Config, config);
49
- fs.write(ui5ConfigPath, ui5Config.toString());
50
- // ui5-deploy.yaml
51
- if ((0, options_1.hasDeployConfig)(config)) {
52
- const ui5DeployConfig = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
53
- (0, options_1.enhanceUI5DeployYaml)(ui5DeployConfig, config);
54
- fs.write((0, path_1.join)(basePath, 'ui5-deploy.yaml'), ui5DeployConfig.toString());
55
- }
56
- });
57
- }
58
42
  /**
59
43
  * Writes the adp-project template to the mem-fs-editor instance.
60
44
  *
@@ -69,11 +53,9 @@ function generate(basePath, config, fs) {
69
53
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
70
54
  }
71
55
  const fullConfig = setDefaults(config);
72
- fs.copyTpl((0, path_1.join)(tmplPath, '**/*.*'), (0, path_1.join)(basePath), fullConfig, undefined, {
73
- globOptions: { dot: true },
74
- processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
75
- });
76
- yield writeUi5Yaml(basePath, fullConfig, fs);
56
+ (0, project_utils_1.writeTemplateToFolder)((0, path_1.join)(tmplPath, '**/*.*'), (0, path_1.join)(basePath), fullConfig, fs);
57
+ yield (0, project_utils_1.writeUI5DeployYaml)(basePath, fullConfig, fs);
58
+ yield (0, project_utils_1.writeUI5Yaml)(basePath, fullConfig, fs);
77
59
  return fs;
78
60
  });
79
61
  }
@@ -105,13 +87,14 @@ function migrate(basePath, config, fs) {
105
87
  });
106
88
  // delete .che folder
107
89
  if (fs.exists((0, path_1.join)(basePath, '.che/project.json'))) {
108
- fs.delete((0, path_1.join)(basePath, '.che/'));
90
+ fs.delete((0, path_1.join)(basePath, '.che/*'));
109
91
  }
110
92
  // delete neo-app.json
111
93
  if (fs.exists((0, path_1.join)(basePath, 'neo-app.json'))) {
112
94
  fs.delete((0, path_1.join)(basePath, 'neo-app.json'));
113
95
  }
114
- yield writeUi5Yaml(basePath, fullConfig, fs);
96
+ yield (0, project_utils_1.writeUI5Yaml)(basePath, fullConfig, fs);
97
+ yield (0, project_utils_1.writeUI5DeployYaml)(basePath, fullConfig, fs);
115
98
  return fs;
116
99
  });
117
100
  }
@@ -1,5 +1,5 @@
1
1
  import type { UI5Config } from '@sap-ux/ui5-config';
2
- import type { AdpWriterConfig } from '../types';
2
+ import type { AdpCustomConfig, AdpWriterConfig } from '../types';
3
3
  /**
4
4
  * Generate the configuration for the middlewares required for the ui5.yaml.
5
5
  *
@@ -27,5 +27,12 @@ export declare function hasDeployConfig(config: AdpWriterConfig): config is AdpW
27
27
  * @param config full project configuration
28
28
  */
29
29
  export declare function enhanceUI5DeployYaml(ui5Config: UI5Config, config: AdpWriterConfigWithDeploy): void;
30
+ /**
31
+ * Generate custom configuration required for the ui5.yaml.
32
+ *
33
+ * @param ui5Config configuration representing the ui5.yaml
34
+ * @param config full project configuration
35
+ */
36
+ export declare function enhanceUI5YamlWithCustomConfig(ui5Config: UI5Config, config?: AdpCustomConfig): void;
30
37
  export {};
31
38
  //# sourceMappingURL=options.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enhanceUI5DeployYaml = exports.hasDeployConfig = exports.enhanceUI5Yaml = void 0;
3
+ exports.enhanceUI5YamlWithCustomConfig = exports.enhanceUI5DeployYaml = exports.hasDeployConfig = exports.enhanceUI5Yaml = void 0;
4
4
  /**
5
5
  * Generate the configuration for the middlewares required for the ui5.yaml.
6
6
  *
@@ -10,6 +10,7 @@ exports.enhanceUI5DeployYaml = exports.hasDeployConfig = exports.enhanceUI5Yaml
10
10
  function enhanceUI5Yaml(ui5Config, config) {
11
11
  var _a;
12
12
  const middlewares = ((_a = config.options) === null || _a === void 0 ? void 0 : _a.fioriTools) ? getFioriToolsMiddlwares(config) : getOpenSourceMiddlewares(config);
13
+ ui5Config.setConfiguration({ propertiesFileSourceEncoding: 'UTF-8' });
13
14
  ui5Config.addCustomMiddleware(middlewares);
14
15
  }
15
16
  exports.enhanceUI5Yaml = enhanceUI5Yaml;
@@ -34,6 +35,19 @@ function enhanceUI5DeployYaml(ui5Config, config) {
34
35
  ui5Config.addAbapDeployTask(config.target, config.deploy, ((_a = config.options) === null || _a === void 0 ? void 0 : _a.fioriTools) === true);
35
36
  }
36
37
  exports.enhanceUI5DeployYaml = enhanceUI5DeployYaml;
38
+ /**
39
+ * Generate custom configuration required for the ui5.yaml.
40
+ *
41
+ * @param ui5Config configuration representing the ui5.yaml
42
+ * @param config full project configuration
43
+ */
44
+ function enhanceUI5YamlWithCustomConfig(ui5Config, config) {
45
+ if (config === null || config === void 0 ? void 0 : config.adp) {
46
+ const { safeMode } = config.adp;
47
+ ui5Config.addCustomConfiguration('adp', { safeMode });
48
+ }
49
+ }
50
+ exports.enhanceUI5YamlWithCustomConfig = enhanceUI5YamlWithCustomConfig;
37
51
  /**
38
52
  * Get a list of required middlewares using the Fiori tools.
39
53
  *
@@ -41,10 +55,20 @@ exports.enhanceUI5DeployYaml = enhanceUI5DeployYaml;
41
55
  * @returns list of required middlewares.
42
56
  */
43
57
  function getFioriToolsMiddlwares(config) {
58
+ var _a, _b, _c, _d;
44
59
  return [
45
60
  {
46
- name: 'fiori-tools-preview',
61
+ name: 'fiori-tools-appreload',
47
62
  afterMiddleware: 'compression',
63
+ configuration: {
64
+ port: 35729,
65
+ path: 'webapp',
66
+ delay: 300,
67
+ }
68
+ },
69
+ {
70
+ name: 'fiori-tools-preview',
71
+ afterMiddleware: 'fiori-tools-appreload',
48
72
  configuration: {
49
73
  adp: {
50
74
  target: config.target,
@@ -58,8 +82,9 @@ function getFioriToolsMiddlwares(config) {
58
82
  configuration: {
59
83
  ignoreCertErrors: false,
60
84
  ui5: {
85
+ version: (_b = (_a = config === null || config === void 0 ? void 0 : config.ui5) === null || _a === void 0 ? void 0 : _a.minVersion) !== null && _b !== void 0 ? _b : '', //default to latest if version is not set
61
86
  path: ['/resources', '/test-resources'],
62
- url: 'https://ui5.sap.com'
87
+ url: (_d = (_c = config === null || config === void 0 ? void 0 : config.ui5) === null || _c === void 0 ? void 0 : _c.frameworkUrl) !== null && _d !== void 0 ? _d : 'https://ui5.sap.com'
63
88
  },
64
89
  backend: [
65
90
  Object.assign(Object.assign({}, config.target), { path: '/sap' })
@@ -76,6 +101,15 @@ function getFioriToolsMiddlwares(config) {
76
101
  */
77
102
  function getOpenSourceMiddlewares(config) {
78
103
  return [
104
+ {
105
+ name: 'reload-middleware',
106
+ afterMiddleware: 'compression',
107
+ configuration: {
108
+ port: 35729,
109
+ path: 'webapp',
110
+ delay: 300,
111
+ }
112
+ },
79
113
  {
80
114
  name: 'preview-middleware',
81
115
  afterMiddleware: 'compression',
@@ -0,0 +1,31 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import { AdpWriterConfig } from '../types';
3
+ /**
4
+ * Writes a given project template files within a specified folder in the project directory.
5
+ *
6
+ * @param {string} templatePath - The root path of the project template.
7
+ * @param {string} projectPath - The root path of the project.
8
+ * @param {CfModuleData | AdpWriterConfig} data - The data to be populated in the template file.
9
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
10
+ * @returns {void}
11
+ */
12
+ export declare function writeTemplateToFolder(templatePath: string, projectPath: string, data: AdpWriterConfig, fs: Editor): void;
13
+ /**
14
+ * Writes a ui5.yaml file within a specified folder in the project directory.
15
+ *
16
+ * @param {string} projectPath - The root path of the project.
17
+ * @param {AdpWriterConfig} data - The data to be populated in the template file.
18
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
19
+ * @returns {void}
20
+ */
21
+ export declare function writeUI5Yaml(projectPath: string, data: AdpWriterConfig, fs: Editor): Promise<void>;
22
+ /**
23
+ * Writes a ui5-deploy.yaml file within a specified folder in the project directory.
24
+ *
25
+ * @param {string} projectPath - The root path of the project.
26
+ * @param {AdpWriterConfig} data - The data to be populated in the template file.
27
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
28
+ * @returns {void}
29
+ */
30
+ export declare function writeUI5DeployYaml(projectPath: string, data: AdpWriterConfig, fs: Editor): Promise<void>;
31
+ //# sourceMappingURL=project-utils.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.writeUI5DeployYaml = exports.writeUI5Yaml = exports.writeTemplateToFolder = void 0;
13
+ const path_1 = require("path");
14
+ const options_1 = require("./options");
15
+ const ui5_config_1 = require("@sap-ux/ui5-config");
16
+ /**
17
+ * Writes a given project template files within a specified folder in the project directory.
18
+ *
19
+ * @param {string} templatePath - The root path of the project template.
20
+ * @param {string} projectPath - The root path of the project.
21
+ * @param {CfModuleData | AdpWriterConfig} data - The data to be populated in the template file.
22
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
23
+ * @returns {void}
24
+ */
25
+ function writeTemplateToFolder(templatePath, projectPath, data, fs) {
26
+ try {
27
+ fs.copyTpl(templatePath, projectPath, data, undefined, {
28
+ globOptions: { dot: true },
29
+ processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
30
+ });
31
+ }
32
+ catch (e) {
33
+ throw new Error(`Could not write template files to folder. Reason: ${e.message}`);
34
+ }
35
+ }
36
+ exports.writeTemplateToFolder = writeTemplateToFolder;
37
+ /**
38
+ * Writes a ui5.yaml file within a specified folder in the project directory.
39
+ *
40
+ * @param {string} projectPath - The root path of the project.
41
+ * @param {AdpWriterConfig} data - The data to be populated in the template file.
42
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
43
+ * @returns {void}
44
+ */
45
+ function writeUI5Yaml(projectPath, data, fs) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ const ui5ConfigPath = (0, path_1.join)(projectPath, 'ui5.yaml');
49
+ const baseUi5ConfigContent = fs.read(ui5ConfigPath);
50
+ const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
51
+ (0, options_1.enhanceUI5Yaml)(ui5Config, data);
52
+ (0, options_1.enhanceUI5YamlWithCustomConfig)(ui5Config, data === null || data === void 0 ? void 0 : data.customConfig);
53
+ fs.write(ui5ConfigPath, ui5Config.toString());
54
+ }
55
+ catch (e) {
56
+ throw new Error(`Could not write ui5.yaml file. Reason: ${e.message}`);
57
+ }
58
+ });
59
+ }
60
+ exports.writeUI5Yaml = writeUI5Yaml;
61
+ /**
62
+ * Writes a ui5-deploy.yaml file within a specified folder in the project directory.
63
+ *
64
+ * @param {string} projectPath - The root path of the project.
65
+ * @param {AdpWriterConfig} data - The data to be populated in the template file.
66
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
67
+ * @returns {void}
68
+ */
69
+ function writeUI5DeployYaml(projectPath, data, fs) {
70
+ return __awaiter(this, void 0, void 0, function* () {
71
+ try {
72
+ if ((0, options_1.hasDeployConfig)(data)) {
73
+ const ui5ConfigPath = (0, path_1.join)(projectPath, 'ui5.yaml');
74
+ const baseUi5ConfigContent = fs.read(ui5ConfigPath);
75
+ const ui5DeployConfig = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
76
+ (0, options_1.enhanceUI5DeployYaml)(ui5DeployConfig, data);
77
+ fs.write((0, path_1.join)(projectPath, 'ui5-deploy.yaml'), ui5DeployConfig.toString());
78
+ }
79
+ }
80
+ catch (e) {
81
+ throw new Error(`Could not write ui5-deploy.yaml file. Reason: ${e.message}`);
82
+ }
83
+ });
84
+ }
85
+ exports.writeUI5DeployYaml = writeUI5DeployYaml;
86
+ //# sourceMappingURL=project-utils.js.map
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.10.6",
12
+ "version": "0.10.8",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -29,10 +29,10 @@
29
29
  "mem-fs-editor": "9.4.0",
30
30
  "prompts": "2.4.2",
31
31
  "adm-zip": "0.5.10",
32
- "@sap-ux/axios-extension": "1.12.3",
32
+ "@sap-ux/axios-extension": "1.12.4",
33
33
  "@sap-ux/project-access": "1.20.0",
34
34
  "@sap-ux/logger": "0.5.1",
35
- "@sap-ux/system-access": "0.3.27",
35
+ "@sap-ux/system-access": "0.3.29",
36
36
  "@sap-ux/ui5-config": "0.22.4",
37
37
  "@sap-ux/btp-utils": "0.14.4"
38
38
  },
@@ -17,7 +17,7 @@
17
17
  "@ui5/cli": "^3.9.1"
18
18
  },
19
19
  "scripts": {
20
- "build": "ui5 build --exclude-task generateFlexChangesBundle generateComponentPreload --clean-dest",
20
+ "build": "ui5 build --exclude-task generateFlexChangesBundle generateComponentPreload minify --clean-dest",
21
21
  "start": "<%= locals.options?.fioriTools ? 'fiori run' : 'ui5 serve' %> --open /test/flp.html#app-preview",
22
22
  "start-editor": "<%= locals.options?.fioriTools ? 'fiori run' : 'ui5 serve' %> --open /test/adaptation-editor.html"<%if (locals.deploy) {%>,
23
23
  "deploy": "ui5 build --config ui5-deploy.yaml --exclude-task <%= locals.options?.fioriTools ? 'deploy-to-abap' : 'abap-deploy-task' %> generateFlexChangesBundle generateComponentPreload --clean-dest && <%= locals.options?.fioriTools ? 'fiori deploy' : 'deploy' %> --config ui5-deploy.yaml",