@sap-ux/fiori-freestyle-writer 2.0.20 → 2.1.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.
@@ -0,0 +1,17 @@
1
+ import type { Package } from '@sap-ux/ui5-application-writer';
2
+ import type { FreestyleApp } from './types';
3
+ import type { Logger } from '@sap-ux/logger';
4
+ import type { Editor } from 'mem-fs-editor';
5
+ /**
6
+ * Generates OPA tests for a freestyle application.
7
+ *
8
+ * @param {string} basePath - The base directory path.
9
+ * @param {FreestyleApp} ffApp - The freestyle application configuration.
10
+ * @param {boolean} addMock - Whether to include the UI5 mock YAML configuration.
11
+ * @param {Package} packageJson - The package.json object to update.
12
+ * @param {Editor} [fs] - Optional file system editor instance.
13
+ * @param {Logger} [log] - Optional logger instance.
14
+ * @returns {Promise<Editor>} - The modified file system editor.
15
+ */
16
+ export declare function generateOPATests<T>(basePath: string, ffApp: FreestyleApp<T>, addMock: boolean, packageJson: Package, fs?: Editor, log?: Logger): Promise<void>;
17
+ //# sourceMappingURL=generateOPATests.d.ts.map
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateOPATests = generateOPATests;
4
+ const ui5_test_writer_1 = require("@sap-ux/ui5-test-writer");
5
+ /**
6
+ * Adds test scripts to the package.json object.
7
+ *
8
+ * @param {Package} packageJson - The package.json object to update.
9
+ * @param {boolean} addMock - Whether to include the UI5 mock YAML configuration.
10
+ */
11
+ function addTestScripts(packageJson, addMock) {
12
+ // Note: 'ui5MockYamlScript' is empty when no data source is selected.
13
+ const ui5MockYamlScript = addMock ? '--config ./ui5-mock.yaml ' : '';
14
+ packageJson.scripts = {
15
+ ...packageJson.scripts,
16
+ 'unit-test': `fiori run ${ui5MockYamlScript}--open 'test/unit/unitTests.qunit.html'`,
17
+ 'int-test': `fiori run ${ui5MockYamlScript}--open 'test/integration/opaTests.qunit.html'`
18
+ };
19
+ }
20
+ /**
21
+ * Generates OPA tests for a freestyle application.
22
+ *
23
+ * @param {string} basePath - The base directory path.
24
+ * @param {FreestyleApp} ffApp - The freestyle application configuration.
25
+ * @param {boolean} addMock - Whether to include the UI5 mock YAML configuration.
26
+ * @param {Package} packageJson - The package.json object to update.
27
+ * @param {Editor} [fs] - Optional file system editor instance.
28
+ * @param {Logger} [log] - Optional logger instance.
29
+ * @returns {Promise<Editor>} - The modified file system editor.
30
+ */
31
+ async function generateOPATests(basePath, ffApp, addMock, packageJson, fs, log) {
32
+ addTestScripts(packageJson, addMock);
33
+ const config = {
34
+ appId: ffApp.app.id,
35
+ applicationDescription: ffApp.app.description,
36
+ applicationTitle: ffApp.app.title,
37
+ viewName: ffApp.template.settings.viewName,
38
+ ui5Theme: ffApp.ui5?.ui5Theme,
39
+ ui5Version: ffApp.ui5?.version,
40
+ enableTypeScript: ffApp.appOptions?.typescript
41
+ };
42
+ await (0, ui5_test_writer_1.generateFreestyleOPAFiles)(basePath, config, fs, log);
43
+ }
44
+ //# sourceMappingURL=generateOPATests.js.map
package/dist/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import { FreestyleApp } from './types';
3
+ import type { Logger } from '@sap-ux/logger';
3
4
  /**
4
5
  * Generate a UI5 application based on the specified Fiori Freestyle floorplan template.
5
6
  *
6
7
  * @param basePath - the absolute target path where the application will be generated
7
8
  * @param data - configuration to generate the freestyle application
8
9
  * @param fs - an optional reference to a mem-fs editor
10
+ * @param log - optional logger
9
11
  * @returns Reference to a mem-fs-editor
10
12
  */
11
- declare function generate<T>(basePath: string, data: FreestyleApp<T>, fs?: Editor): Promise<Editor>;
13
+ declare function generate<T>(basePath: string, data: FreestyleApp<T>, fs?: Editor, log?: Logger): Promise<Editor>;
12
14
  export { generate, FreestyleApp };
13
15
  export { WorklistSettings, ListDetailSettings, TemplateType, Template, OdataVersion } from './types';
14
16
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -17,15 +17,17 @@ const i18n_1 = require("./i18n");
17
17
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
18
18
  const utils_1 = require("./utils");
19
19
  const cap_config_writer_1 = require("@sap-ux/cap-config-writer");
20
+ const generateOPATests_1 = require("./generateOPATests");
20
21
  /**
21
22
  * Generate a UI5 application based on the specified Fiori Freestyle floorplan template.
22
23
  *
23
24
  * @param basePath - the absolute target path where the application will be generated
24
25
  * @param data - configuration to generate the freestyle application
25
26
  * @param fs - an optional reference to a mem-fs editor
27
+ * @param log - optional logger
26
28
  * @returns Reference to a mem-fs-editor
27
29
  */
28
- async function generate(basePath, data, fs) {
30
+ async function generate(basePath, data, fs, log) {
29
31
  // Load i18n translations asynchronously to ensure proper initialization.
30
32
  // This addresses occasional issues where i18n is not initialized in time, causing tests to fail.
31
33
  await (0, i18n_1.initI18n)();
@@ -81,21 +83,27 @@ async function generate(basePath, data, fs) {
81
83
  const packagePath = (0, path_1.join)(basePath, 'package.json');
82
84
  // extend package.json with scripts for non-CAP projects
83
85
  fs.extendJSON(packagePath, JSON.parse((0, ejs_1.render)(fs.read((0, path_1.join)(tmplPath, 'common', 'extend', 'package.json')), ffApp, {})));
86
+ const addTests = ffApp.appOptions?.addTests;
84
87
  const packageJson = JSON.parse(fs.read(packagePath));
85
88
  if (isEdmxProjectType) {
89
+ const addMock = !!ffApp.service?.metadata;
86
90
  // Add scripts for non-CAP applications
87
91
  packageJson.scripts = {
88
92
  ...packageJson.scripts,
89
93
  ...(0, fiori_generator_shared_1.getPackageScripts)({
90
94
  localOnly: !!ffApp.service && !ffApp.service?.url,
91
- addMock: !!ffApp.service?.metadata,
95
+ addMock,
92
96
  sapClient: ffApp.service?.client,
93
97
  flpAppId: ffApp.app.flpAppId,
94
98
  startFile: data?.app?.startFile,
95
99
  localStartFile: data?.app?.localStartFile,
96
- generateIndex: ffApp.appOptions?.generateIndex
100
+ generateIndex: ffApp.appOptions?.generateIndex,
101
+ addTest: addTests
97
102
  })
98
103
  };
104
+ if (addTests) {
105
+ await (0, generateOPATests_1.generateOPATests)(basePath, ffApp, addMock, packageJson, fs, log);
106
+ }
99
107
  }
100
108
  else {
101
109
  // Add deploy-config for CAP applications
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Ui5App, App } from '@sap-ux/ui5-application-writer';
1
+ import type { Ui5App, App, AppOptions } from '@sap-ux/ui5-application-writer';
2
2
  import type { OdataService } from '@sap-ux/odata-service-writer';
3
3
  import type { CapServiceCdsInfo } from '@sap-ux/cap-config-writer';
4
4
  export declare const TemplateType: {
@@ -37,6 +37,13 @@ export interface FreestyleApp<T> extends Ui5App {
37
37
  capService?: CapServiceCdsInfo;
38
38
  };
39
39
  app: FioriApp;
40
+ appOptions?: Partial<AppOptions> & {
41
+ /**
42
+ * Generate OPA based tests, for Simple template.
43
+ * This will eventually move up to {@link Ui5App.appOptions}
44
+ */
45
+ addTests?: boolean;
46
+ };
40
47
  }
41
48
  export { OdataVersion } from '@sap-ux/odata-service-writer';
42
49
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-freestyle-writer",
3
3
  "description": "SAP Fiori freestyle application writer",
4
- "version": "2.0.20",
4
+ "version": "2.1.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,9 +29,11 @@
29
29
  "semver": "7.5.4",
30
30
  "@sap-ux/odata-service-writer": "0.26.3",
31
31
  "@sap-ux/ui5-application-writer": "1.2.10",
32
+ "@sap-ux/fiori-generator-shared": "0.9.0",
33
+ "@sap-ux/cap-config-writer": "0.9.11",
34
+ "@sap-ux/ui5-test-writer": "0.5.1",
32
35
  "@sap-ux/ui5-config": "0.26.2",
33
- "@sap-ux/fiori-generator-shared": "0.8.1",
34
- "@sap-ux/cap-config-writer": "0.9.10"
36
+ "@sap-ux/logger": "0.6.0"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@types/ejs": "3.1.2",
@@ -3,7 +3,8 @@
3
3
  "rootView": {
4
4
  "viewName": "<%- app.id %>.view.App",
5
5
  "type": "XML",
6
- "id": "App"
6
+ "id": "App",
7
+ "async": true
7
8
  },
8
9
  "resources": {
9
10
  "css": [
@@ -20,7 +21,9 @@
20
21
  "transition": "slide",
21
22
  "type": "View",
22
23
  "viewType": "XML",
23
- "path": "<%- app.id %>.view"
24
+ "path": "<%- app.id %>.view",
25
+ "async": true,
26
+ "viewPath": "<%- app.id %>.view"
24
27
  },
25
28
  "routes": [
26
29
  {