@sap-ux/fiori-elements-writer 2.4.0 → 2.4.2

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -9
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -68,6 +68,33 @@ function getTypeScriptIgnoreGlob(feApp, coercedUI5Version) {
68
68
  }
69
69
  return ignore;
70
70
  }
71
+ /**
72
+ * Returns the OPA config.
73
+ *
74
+ * @param appOpts - relevant app options for retrieving the opa config
75
+ * @param appOpts.generateIndex - if an index.html file will be generated
76
+ * @param appOpts.useVirtualPreviewEndpoints - if virtual endpoints will be used for preview
77
+ * @param flpAppId - the flp app id
78
+ * @returns - the opa config { htmlTarget }
79
+ */
80
+ function getOpaConfig({ generateIndex, useVirtualPreviewEndpoints }, flpAppId) {
81
+ const flpTarget = useVirtualPreviewEndpoints ? 'flp' : 'flpSandbox';
82
+ const htmlTarget = generateIndex ? 'index.html' : `test/${flpTarget}.html?sap-ui-xx-viewCache=false#${flpAppId}`;
83
+ return {
84
+ htmlTarget
85
+ };
86
+ }
87
+ /**
88
+ * Determines if tests should be added.
89
+ * For now, only if v4 and we have metadata (and therefore a mock server config) or has a cds service.
90
+ *
91
+ * @param service - the service data
92
+ * @param addTests - app option to add tests
93
+ * @returns - boolean indicating if tests are to be added
94
+ */
95
+ function shouldAddTest(service, addTests) {
96
+ return (!!addTests && service?.version === odata_service_writer_1.OdataVersion.v4 && (!!service?.metadata || service?.type === odata_service_writer_1.ServiceType.CDS));
97
+ }
71
98
  /**
72
99
  * Generate a UI5 application based on the specified Fiori Elements floorplan template.
73
100
  *
@@ -150,10 +177,7 @@ async function generate(basePath, data, fs, log) {
150
177
  // Update manifest.json with template specific settings
151
178
  (0, manifestSettings_1.extendManifestJson)(fs, basePath, rootTemplatesPath, feApp);
152
179
  const packageJson = JSON.parse(fs.read(packagePath));
153
- // Add tests only if v4, for now, and we have metadata (and therefore a mock server config) or has a cds service
154
- const addTest = !!feApp.appOptions.addTests &&
155
- feApp.service?.version === odata_service_writer_1.OdataVersion.v4 &&
156
- (!!feApp.service?.metadata || feApp.service.type === odata_service_writer_1.ServiceType.CDS);
180
+ const addTest = shouldAddTest(feApp.service, feApp.appOptions?.addTests);
157
181
  if (isEdmxProjectType) {
158
182
  // Add scripts to package.json only for non-CAP projects
159
183
  packageJson.scripts = Object.assign(packageJson.scripts ?? {}, {
@@ -177,11 +201,11 @@ async function generate(basePath, data, fs, log) {
177
201
  }
178
202
  fs.writeJSON(packagePath, packageJson);
179
203
  if (addTest) {
180
- (0, ui5_test_writer_1.generateOPAFiles)(basePath, {
181
- htmlTarget: feApp.appOptions?.generateIndex
182
- ? 'index.html'
183
- : `test/flpSandbox.html?sap-ui-xx-viewCache=false#${feApp.app.flpAppId}`
184
- }, fs);
204
+ const opaConfig = getOpaConfig({
205
+ generateIndex: feApp.appOptions?.generateIndex,
206
+ useVirtualPreviewEndpoints: feApp.appOptions?.useVirtualPreviewEndpoints
207
+ }, feApp.app.flpAppId);
208
+ (0, ui5_test_writer_1.generateOPAFiles)(basePath, opaConfig, fs);
185
209
  }
186
210
  if (feApp.service.capService) {
187
211
  const enableCdsUi5Plugin = !!feApp?.appOptions?.typescript || !!feApp?.service.capService?.cdsUi5PluginInfo?.isCdsUi5PluginEnabled;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-elements-writer",
3
3
  "description": "SAP Fiori elements application writer",
4
- "version": "2.4.0",
4
+ "version": "2.4.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -27,14 +27,14 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "read-pkg-up": "7.0.1",
29
29
  "semver": "7.5.4",
30
- "@sap-ux/odata-service-writer": "0.27.0",
31
- "@sap-ux/ui5-application-writer": "1.5.0",
32
- "@sap-ux/fe-fpm-writer": "0.34.0",
33
- "@sap-ux/ui5-config": "0.28.0",
34
- "@sap-ux/ui5-test-writer": "0.7.0",
35
- "@sap-ux/fiori-generator-shared": "0.12.0",
36
- "@sap-ux/cap-config-writer": "0.10.0",
37
- "@sap-ux/annotation-generator": "0.3.32",
30
+ "@sap-ux/ui5-application-writer": "1.5.1",
31
+ "@sap-ux/ui5-config": "0.28.1",
32
+ "@sap-ux/ui5-test-writer": "0.7.1",
33
+ "@sap-ux/fe-fpm-writer": "0.34.1",
34
+ "@sap-ux/odata-service-writer": "0.27.1",
35
+ "@sap-ux/fiori-generator-shared": "0.12.1",
36
+ "@sap-ux/cap-config-writer": "0.10.1",
37
+ "@sap-ux/annotation-generator": "0.3.33",
38
38
  "@sap-ux/logger": "0.7.0"
39
39
  },
40
40
  "devDependencies": {