@sap-ux/adp-tooling 0.6.0 → 0.7.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.
@@ -3,18 +3,19 @@ export declare const enum flexLayer {
3
3
  CUSTOMER_BASE = "CUSTOMER_BASE",
4
4
  VENDOR = "VENDOR"
5
5
  }
6
+ export type PromptDefaults = {
7
+ id?: string;
8
+ reference?: string;
9
+ url?: string;
10
+ ft?: boolean;
11
+ package?: string;
12
+ transport?: string;
13
+ };
6
14
  /**
7
15
  * Prompt the user for the required properties for an adaptation project.
8
16
  *
9
17
  * @param defaults optional default values for the prompts
10
- * @param defaults.id initial id to be used for the new adaptation id prompt
11
- * @param defaults.reference initial id used for the original application id prompt
12
- * @param defaults.url initial url used for the target url prompt
13
18
  * @returns a configuration for the adp writer
14
19
  */
15
- export declare function promptGeneratorInput({ id, reference, url }?: {
16
- id?: string;
17
- reference?: string;
18
- url?: string;
19
- }): Promise<AdpWriterConfig>;
20
+ export declare function promptGeneratorInput(defaults?: PromptDefaults): Promise<AdpWriterConfig>;
20
21
  //# sourceMappingURL=prompt.d.ts.map
@@ -18,12 +18,10 @@ const prompts_1 = __importDefault(require("prompts"));
18
18
  * Prompt the user for the required properties for an adaptation project.
19
19
  *
20
20
  * @param defaults optional default values for the prompts
21
- * @param defaults.id initial id to be used for the new adaptation id prompt
22
- * @param defaults.reference initial id used for the original application id prompt
23
- * @param defaults.url initial url used for the target url prompt
24
21
  * @returns a configuration for the adp writer
25
22
  */
26
- function promptGeneratorInput({ id, reference, url } = {}) {
23
+ function promptGeneratorInput(defaults = {}) {
24
+ var _a;
27
25
  return __awaiter(this, void 0, void 0, function* () {
28
26
  const app = yield (0, prompts_1.default)([
29
27
  {
@@ -46,7 +44,7 @@ function promptGeneratorInput({ id, reference, url } = {}) {
46
44
  return 'New adaptation id:';
47
45
  }
48
46
  },
49
- initial: id,
47
+ initial: defaults.id,
50
48
  format: (input, values) => {
51
49
  if (values.layer === "CUSTOMER_BASE" /* flexLayer.CUSTOMER_BASE */ && !input.startsWith('customer.')) {
52
50
  return `customer.${input}`;
@@ -61,7 +59,7 @@ function promptGeneratorInput({ id, reference, url } = {}) {
61
59
  type: 'text',
62
60
  name: 'reference',
63
61
  message: 'Original application id:',
64
- initial: reference,
62
+ initial: defaults.reference,
65
63
  validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
66
64
  },
67
65
  {
@@ -75,11 +73,41 @@ function promptGeneratorInput({ id, reference, url } = {}) {
75
73
  type: 'text',
76
74
  name: 'url',
77
75
  message: 'Target system url:',
78
- initial: url,
76
+ initial: defaults.url,
77
+ validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
78
+ },
79
+ {
80
+ type: 'text',
81
+ name: 'client',
82
+ message: 'Client (optional):',
83
+ validate: (input) => (input ? input.length < 4 : true)
84
+ }
85
+ ]);
86
+ const deploy = yield (0, prompts_1.default)([
87
+ {
88
+ type: 'text',
89
+ name: 'package',
90
+ message: 'Deployment package:',
91
+ initial: (_a = defaults.package) !== null && _a !== void 0 ? _a : '$TMP',
92
+ validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
93
+ },
94
+ {
95
+ type: 'text',
96
+ name: 'transport',
97
+ message: 'Transport request (optional):',
98
+ initial: defaults.transport
99
+ }
100
+ ]);
101
+ const options = yield (0, prompts_1.default)([
102
+ {
103
+ type: 'confirm',
104
+ name: 'fioriTools',
105
+ message: 'Enable Fiori tools?',
106
+ initial: defaults.ft !== false,
79
107
  validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
80
108
  }
81
109
  ]);
82
- return { app, target };
110
+ return { app, target, options, deploy };
83
111
  });
84
112
  }
85
113
  exports.promptGeneratorInput = promptGeneratorInput;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AdpPreviewConfig, AdpWriterConfig } from './types';
2
2
  export * from './preview/adp-preview';
3
3
  export { generate } from './writer';
4
- export * from './base/prompt';
4
+ export { promptGeneratorInput, PromptDefaults } from './base/prompt';
5
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.generate = void 0;
17
+ exports.promptGeneratorInput = exports.generate = void 0;
18
18
  __exportStar(require("./preview/adp-preview"), exports);
19
19
  var writer_1 = require("./writer");
20
20
  Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return writer_1.generate; } });
21
- __exportStar(require("./base/prompt"), exports);
21
+ var prompt_1 = require("./base/prompt");
22
+ Object.defineProperty(exports, "promptGeneratorInput", { enumerable: true, get: function () { return prompt_1.promptGeneratorInput; } });
22
23
  //# sourceMappingURL=index.js.map
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { UI5FlexLayer } from '@sap-ux/project-access';
2
2
  import type { DestinationAbapTarget, UrlAbapTarget } from '@sap-ux/system-access';
3
+ import type { Adp } from '@sap-ux/ui5-config';
3
4
  export interface DescriptorVariant {
4
5
  layer: UI5FlexLayer;
5
6
  reference: string;
@@ -33,6 +34,16 @@ export interface AdpWriterConfig {
33
34
  name?: string;
34
35
  description?: string;
35
36
  };
37
+ /**
38
+ * Optional: configuration for deployment to ABAP
39
+ */
40
+ deploy?: Adp;
41
+ options?: {
42
+ /**
43
+ * Optional: if set to true then the generated project will be recognized by the SAP Fiori tools
44
+ */
45
+ fioriTools?: boolean;
46
+ };
36
47
  }
37
48
  export interface ManifestAppdescr {
38
49
  fileName: string;
@@ -1,7 +1,7 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { AdpWriterConfig } from '../types';
3
3
  /**
4
- * Writes the adp-project template to the memfs editor instance.
4
+ * Writes the adp-project template to the mem-fs-editor instance.
5
5
  *
6
6
  * @param basePath - the base path
7
7
  * @param config - the writer configuration
@@ -14,6 +14,7 @@ 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
16
  const ui5_config_1 = require("@sap-ux/ui5-config");
17
+ const options_1 = require("./options");
17
18
  /**
18
19
  * Set default values for optional properties.
19
20
  *
@@ -26,7 +27,9 @@ function setDefaults(config) {
26
27
  const configWithDefaults = {
27
28
  app: Object.assign({}, config.app),
28
29
  target: Object.assign({}, config.target),
29
- ui5: Object.assign({}, config.ui5)
30
+ ui5: Object.assign({}, config.ui5),
31
+ deploy: config.deploy ? Object.assign({}, config.deploy) : undefined,
32
+ options: Object.assign({}, config.options)
30
33
  };
31
34
  (_a = (_f = configWithDefaults.app).title) !== null && _a !== void 0 ? _a : (_f.title = `Adaptation of ${config.app.reference}`);
32
35
  (_b = (_g = configWithDefaults.app).layer) !== null && _b !== void 0 ? _b : (_g.layer = 'CUSTOMER_BASE');
@@ -36,7 +39,7 @@ function setDefaults(config) {
36
39
  return configWithDefaults;
37
40
  }
38
41
  /**
39
- * Writes the adp-project template to the memfs editor instance.
42
+ * Writes the adp-project template to the mem-fs-editor instance.
40
43
  *
41
44
  * @param basePath - the base path
42
45
  * @param config - the writer configuration
@@ -56,48 +59,16 @@ function generate(basePath, config, fs) {
56
59
  });
57
60
  // ui5.yaml
58
61
  const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
59
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
60
- ui5Config.addCustomMiddleware([
61
- {
62
- name: 'preview-middleware',
63
- afterMiddleware: 'compression',
64
- configuration: {
65
- adp: {
66
- target: fullConfig.target,
67
- ignoreCertErrors: false
68
- },
69
- rta: {
70
- editors: [
71
- {
72
- path: '/local/editor.html',
73
- developerMode: true
74
- }
75
- ]
76
- }
77
- }
78
- },
79
- {
80
- name: 'ui5-proxy-middleware',
81
- afterMiddleware: 'preview-middleware',
82
- configuration: {
83
- ui5: {
84
- path: ['/resources', '/test-resources'],
85
- url: 'https://ui5.sap.com'
86
- }
87
- }
88
- },
89
- {
90
- name: 'backend-proxy-middleware',
91
- afterMiddleware: 'preview-middleware',
92
- configuration: {
93
- backend: Object.assign(Object.assign({}, fullConfig.target), { path: '/sap' }),
94
- options: {
95
- secure: true
96
- }
97
- }
98
- }
99
- ]);
62
+ const baseUi5ConfigContent = fs.read(ui5ConfigPath);
63
+ const ui5Config = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
64
+ (0, options_1.enhanceUI5Yaml)(ui5Config, fullConfig);
100
65
  fs.write(ui5ConfigPath, ui5Config.toString());
66
+ // ui5-deploy.yaml
67
+ if ((0, options_1.hasDeployConfig)(fullConfig)) {
68
+ const ui5DeployConfig = yield ui5_config_1.UI5Config.newInstance(baseUi5ConfigContent);
69
+ (0, options_1.enhanceUI5DeployYaml)(ui5DeployConfig, fullConfig);
70
+ fs.write((0, path_1.join)(basePath, 'ui5-deploy.yaml'), ui5DeployConfig.toString());
71
+ }
101
72
  return fs;
102
73
  });
103
74
  }
@@ -0,0 +1,31 @@
1
+ import type { UI5Config } from '@sap-ux/ui5-config';
2
+ import type { AdpWriterConfig } from '../types';
3
+ /**
4
+ * Generate the configuration for the middlewares required for the ui5.yaml.
5
+ *
6
+ * @param ui5Config configuration representing the ui5.yaml
7
+ * @param config full project configuration
8
+ */
9
+ export declare function enhanceUI5Yaml(ui5Config: UI5Config, config: AdpWriterConfig): void;
10
+ /**
11
+ * Writer configuration with deploy configuration.
12
+ */
13
+ type AdpWriterConfigWithDeploy = AdpWriterConfig & {
14
+ deploy: NonNullable<AdpWriterConfig['deploy']>;
15
+ };
16
+ /**
17
+ * Checks if a writer config has a deploy configuration.
18
+ *
19
+ * @param config a writer configuration
20
+ * @returns typecasted config if it contains a deploy config
21
+ */
22
+ export declare function hasDeployConfig(config: AdpWriterConfig): config is AdpWriterConfigWithDeploy;
23
+ /**
24
+ * Generate the configuration for the tasks required for the ui5-deploy.yaml.
25
+ *
26
+ * @param ui5Config configuration representing the ui5.yaml
27
+ * @param config full project configuration
28
+ */
29
+ export declare function enhanceUI5DeployYaml(ui5Config: UI5Config, config: AdpWriterConfigWithDeploy): void;
30
+ export {};
31
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enhanceUI5DeployYaml = exports.hasDeployConfig = exports.enhanceUI5Yaml = void 0;
4
+ /**
5
+ * Generate the configuration for the middlewares required for the ui5.yaml.
6
+ *
7
+ * @param ui5Config configuration representing the ui5.yaml
8
+ * @param config full project configuration
9
+ */
10
+ function enhanceUI5Yaml(ui5Config, config) {
11
+ var _a;
12
+ const middlewares = ((_a = config.options) === null || _a === void 0 ? void 0 : _a.fioriTools) ? getFioriToolsMiddlwares(config) : getOpenSourceMiddlewares(config);
13
+ ui5Config.addCustomMiddleware(middlewares);
14
+ }
15
+ exports.enhanceUI5Yaml = enhanceUI5Yaml;
16
+ /**
17
+ * Checks if a writer config has a deploy configuration.
18
+ *
19
+ * @param config a writer configuration
20
+ * @returns typecasted config if it contains a deploy config
21
+ */
22
+ function hasDeployConfig(config) {
23
+ return !!config.deploy;
24
+ }
25
+ exports.hasDeployConfig = hasDeployConfig;
26
+ /**
27
+ * Generate the configuration for the tasks required for the ui5-deploy.yaml.
28
+ *
29
+ * @param ui5Config configuration representing the ui5.yaml
30
+ * @param config full project configuration
31
+ */
32
+ function enhanceUI5DeployYaml(ui5Config, config) {
33
+ var _a;
34
+ ui5Config.addAbapDeployTask(config.target, config.deploy, ((_a = config.options) === null || _a === void 0 ? void 0 : _a.fioriTools) === true);
35
+ }
36
+ exports.enhanceUI5DeployYaml = enhanceUI5DeployYaml;
37
+ /**
38
+ * Get a list of required middlewares using the Fiori tools.
39
+ *
40
+ * @param config full project configuration
41
+ * @returns list of required middlewares.
42
+ */
43
+ function getFioriToolsMiddlwares(config) {
44
+ return [
45
+ {
46
+ name: 'fiori-tools-preview',
47
+ afterMiddleware: 'compression',
48
+ configuration: {
49
+ adp: {
50
+ target: config.target,
51
+ ignoreCertErrors: false
52
+ }
53
+ }
54
+ },
55
+ {
56
+ name: 'fiori-tools-proxy',
57
+ afterMiddleware: 'fiori-tools-preview',
58
+ configuration: {
59
+ ignoreCertErrors: false,
60
+ ui5: {
61
+ path: ['/resources', '/test-resources'],
62
+ url: 'https://ui5.sap.com'
63
+ },
64
+ backend: [
65
+ Object.assign(Object.assign({}, config.target), { path: '/sap' })
66
+ ]
67
+ }
68
+ }
69
+ ];
70
+ }
71
+ /**
72
+ * Get a list of required middlewares using the open source middlewares.
73
+ *
74
+ * @param config full project configuration
75
+ * @returns list of required middlewares.
76
+ */
77
+ function getOpenSourceMiddlewares(config) {
78
+ return [
79
+ {
80
+ name: 'preview-middleware',
81
+ afterMiddleware: 'compression',
82
+ configuration: {
83
+ adp: {
84
+ target: config.target,
85
+ ignoreCertErrors: false
86
+ },
87
+ rta: {
88
+ editors: [
89
+ {
90
+ path: '/test/adaptation-editor.html',
91
+ developerMode: true
92
+ }
93
+ ]
94
+ }
95
+ }
96
+ },
97
+ {
98
+ name: 'ui5-proxy-middleware',
99
+ afterMiddleware: 'preview-middleware'
100
+ },
101
+ {
102
+ name: 'backend-proxy-middleware',
103
+ afterMiddleware: 'preview-middleware',
104
+ configuration: {
105
+ backend: Object.assign(Object.assign({}, config.target), { path: '/sap' }),
106
+ options: {
107
+ secure: true
108
+ }
109
+ }
110
+ }
111
+ ];
112
+ }
113
+ //# sourceMappingURL=options.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.6.0",
12
+ "version": "0.7.0",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "@sap-ux/axios-extension": "1.7.3",
33
33
  "@sap-ux/logger": "0.4.0",
34
34
  "@sap-ux/system-access": "0.3.5",
35
- "@sap-ux/ui5-config": "0.20.0"
35
+ "@sap-ux/ui5-config": "0.21.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/ejs": "3.1.2",
@@ -46,7 +46,7 @@
46
46
  "nock": "13.2.1",
47
47
  "rimraf": "5.0.1",
48
48
  "supertest": "6.3.3",
49
- "@sap-ux/project-access": "1.15.1",
49
+ "@sap-ux/project-access": "1.15.4",
50
50
  "@sap-ux/store": "0.4.0"
51
51
  },
52
52
  "peerDependencies": {
@@ -5,19 +5,22 @@
5
5
  "description": "<%= package.description %>",
6
6
  "keywords": [
7
7
  "ui5",
8
- "openui5",
9
- "sapui5"
8
+ "sapui5",
9
+ "adaptation-project"
10
10
  ],
11
11
  "dependencies": {},
12
12
  "devDependencies": {
13
- "@sap-ux/backend-proxy-middleware": "^0.6.68",
14
- "@sap-ux/preview-middleware": "^0.5.0",
15
- "@sap-ux/ui5-proxy-middleware": "^1.1.34",
13
+ <%if (locals.options?.fioriTools) {%>"@sap/ux-ui5-tooling": "^1.11.4"<%} else {%>"@sap-ux/backend-proxy-middleware": "^0.7.5",
14
+ "@sap-ux/preview-middleware": "^0.11.1",
15
+ "@sap-ux/ui5-proxy-middleware": "^1.3.0",
16
+ "@sap-ux/deploy-tooling": "^0.11.7"<%}%>,
16
17
  "@ui5/cli": "^3.6.0"
17
18
  },
18
19
  "scripts": {
19
20
  "build": "ui5 build --exclude-task generateFlexChangesBundle generateComponentPreload --clean-dest",
20
- "start": "ui5 serve --open /test/flp.html#app-preview",
21
- "editor": "ui5 serve --open /local/editor.html"
21
+ "start": "<%= locals.options?.fioriTools ? 'fiori run' : 'ui5 serve' %> --open /test/flp.html#app-preview",
22
+ "start-editor": "<%= locals.options?.fioriTools ? 'fiori run' : 'ui5 serve' %> --open /test/adaptation-editor.html"<%if (locals.deploy) {%>,
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",
24
+ "undeploy": "<%= locals.options?.fioriTools ? 'fiori undeploy' : 'undeploy' %> --config ui5-deploy.yaml --lrep 'apps/<%= app.reference %>/appVariants/<%= app.id %>/'"<%}%>
22
25
  }
23
26
  }