@sap-ux/fiori-elements-writer 0.23.2 → 1.0.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.
@@ -1,6 +1,7 @@
1
1
  import { OdataVersion } from '@sap-ux/odata-service-writer';
2
2
  import type { FioriElementsApp, Template } from '../types';
3
3
  import { TemplateType } from '../types';
4
+ import { type TemplateOptions } from './templateAttributes';
4
5
  /**
5
6
  * Updates the template settings to defaults if not provided.
6
7
  *
@@ -25,4 +26,13 @@ export declare function getUi5Libs(type: TemplateType, version: OdataVersion, ui
25
26
  * @returns Fiori elements app config with updated defaults for unspecified properties
26
27
  */
27
28
  export declare function setAppDefaults<T>(feApp: FioriElementsApp<T>): FioriElementsApp<T>;
29
+ /**
30
+ * Generates template options on project type and version information.
31
+ *
32
+ * @param {boolean} isEdmxProjectType Indicates if the project type is 'EDMXBackend'.
33
+ * @param {string} serviceVersion The version of the service being used.
34
+ * @param {string} [ui5Version] The version of UI5 framework being used.
35
+ * @returns {TemplateOptions} An template objects containing options related to changes preview and loader.
36
+ */
37
+ export declare function getTemplateOptions(isEdmxProjectType: boolean, serviceVersion: string, ui5Version?: string): TemplateOptions;
28
38
  //# sourceMappingURL=defaults.d.ts.map
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setAppDefaults = exports.getUi5Libs = exports.setDefaultTemplateSettings = void 0;
6
+ exports.getTemplateOptions = exports.setAppDefaults = exports.getUi5Libs = exports.setDefaultTemplateSettings = void 0;
7
7
  const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
8
8
  const read_pkg_up_1 = __importDefault(require("read-pkg-up"));
9
9
  const types_1 = require("../types");
10
10
  const templateAttributes_1 = require("./templateAttributes");
11
11
  const annotationCustomUi5Libs_1 = require("./annotationCustomUi5Libs");
12
+ const semver_1 = __importDefault(require("semver"));
12
13
  const defaultModelName = 'mainModel'; // UI5 default model name is '' but some floorplans require a named default model
13
14
  /**
14
15
  * Updates the template settings to defaults if not provided.
@@ -120,4 +121,26 @@ function setAppDefaults(feApp) {
120
121
  return feApp;
121
122
  }
122
123
  exports.setAppDefaults = setAppDefaults;
124
+ /**
125
+ * Generates template options on project type and version information.
126
+ *
127
+ * @param {boolean} isEdmxProjectType Indicates if the project type is 'EDMXBackend'.
128
+ * @param {string} serviceVersion The version of the service being used.
129
+ * @param {string} [ui5Version] The version of UI5 framework being used.
130
+ * @returns {TemplateOptions} An template objects containing options related to changes preview and loader.
131
+ */
132
+ function getTemplateOptions(isEdmxProjectType, serviceVersion, ui5Version) {
133
+ const coercedUI5Version = semver_1.default.coerce(ui5Version);
134
+ // Determine if the changes preview should be enabled based on the project type and UI5 version
135
+ const changesPreview = isEdmxProjectType && ui5Version
136
+ ? semver_1.default.lt(coercedUI5Version, templateAttributes_1.changesPreviewToVersion) // Check if the coerced version is less than the required version
137
+ : false;
138
+ // Determine if the changes loader should be enabled based on the project type and service version
139
+ const changesLoader = isEdmxProjectType && serviceVersion === odata_service_writer_1.OdataVersion.v2;
140
+ return {
141
+ changesPreview,
142
+ changesLoader
143
+ };
144
+ }
145
+ exports.getTemplateOptions = getTemplateOptions;
123
146
  //# sourceMappingURL=defaults.js.map
package/dist/index.js CHANGED
@@ -33,10 +33,10 @@ const templateAttributes_1 = require("./data/templateAttributes");
33
33
  Object.defineProperty(exports, "TemplateTypeAttributes", { enumerable: true, get: function () { return templateAttributes_1.TemplateTypeAttributes; } });
34
34
  Object.defineProperty(exports, "minSupportedUI5Version", { enumerable: true, get: function () { return templateAttributes_1.minSupportedUI5Version; } });
35
35
  Object.defineProperty(exports, "minSupportedUI5VersionV4", { enumerable: true, get: function () { return templateAttributes_1.minSupportedUI5VersionV4; } });
36
- const templateAttributes_2 = require("./data/templateAttributes");
37
36
  const manifestSettings_1 = require("./data/manifestSettings");
38
37
  const semver_1 = __importDefault(require("semver"));
39
38
  const i18n_1 = require("./i18n");
39
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
40
40
  exports.V2_FE_TYPES_AVAILABLE = '1.108.0';
41
41
  /**
42
42
  * Get TypeScript Ignore Glob Pattern.
@@ -89,10 +89,6 @@ async function generate(basePath, data, fs) {
89
89
  (0, validate_1.validateApp)(feApp);
90
90
  await (0, odata_service_writer_1.generate)(basePath, feApp.service, fs);
91
91
  const coercedUI5Version = semver_1.default.coerce(feApp.ui5?.version);
92
- const templateOptions = {
93
- changesPreview: feApp.ui5?.version ? semver_1.default.lt(coercedUI5Version, templateAttributes_2.changesPreviewToVersion) : false,
94
- changesLoader: feApp.service.version === odata_service_writer_1.OdataVersion.v2
95
- };
96
92
  // Add new files from templates e.g.
97
93
  const rootTemplatesPath = (0, path_1.join)(__dirname, '..', 'templates');
98
94
  // Add templates common to all template types
@@ -101,10 +97,31 @@ async function generate(basePath, data, fs) {
101
97
  if (feApp.appOptions?.typescript === true) {
102
98
  ignore = getTypeScriptIgnoreGlob(feApp, coercedUI5Version);
103
99
  }
104
- fs.copyTpl((0, path_1.join)(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
100
+ // Determine if the project type is 'EDMXBackend'.
101
+ const isEdmxProjectType = feApp.app.projectType === 'EDMXBackend';
102
+ // Get resource bootstrap URLs based on the project type
103
+ const { uShellBootstrapResourceUrl, uiBootstrapResourceUrl } = (0, fiori_generator_shared_1.getBootstrapResourceUrls)(isEdmxProjectType, feApp.ui5?.frameworkUrl, feApp.ui5?.version);
104
+ const ui5Libs = isEdmxProjectType ? feApp.ui5?.ui5Libs : undefined;
105
+ // Define template options with changes preview and loader settings based on project type
106
+ const templateOptions = (0, defaults_1.getTemplateOptions)(isEdmxProjectType, feApp.service.version, feApp.ui5?.version);
107
+ const appConfig = {
105
108
  ...feApp,
106
109
  templateOptions,
107
- escapeFLPText: templateAttributes_2.escapeFLPText
110
+ uShellBootstrapResourceUrl,
111
+ uiBootstrapResourceUrl,
112
+ ui5Libs
113
+ };
114
+ // Copy templates with configuration
115
+ fs.copyTpl((0, path_1.join)(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
116
+ ...appConfig,
117
+ escapeFLPText: templateAttributes_1.escapeFLPText
118
+ }, undefined, {
119
+ globOptions: { ignore, dot: true }
120
+ });
121
+ fs.copyTpl((0, path_1.join)(rootTemplatesPath, 'common', 'add', '**/*.*'), basePath, {
122
+ ...appConfig,
123
+ templateOptions,
124
+ escapeFLPText: templateAttributes_1.escapeFLPText
108
125
  }, undefined, {
109
126
  globOptions: { ignore, dot: true }
110
127
  });
@@ -136,18 +153,27 @@ async function generate(basePath, data, fs) {
136
153
  const addTest = !!feApp.appOptions.addTests &&
137
154
  feApp.service?.version === odata_service_writer_1.OdataVersion.v4 &&
138
155
  (!!feApp.service?.metadata || feApp.service.type === odata_service_writer_1.ServiceType.CDS);
139
- packageJson.scripts = Object.assign(packageJson.scripts ?? {}, {
140
- ...(0, packageConfig_1.getPackageJsonTasks)({
141
- localOnly: !feApp.service?.url,
142
- addMock: !!feApp.service?.metadata,
143
- addTest,
144
- sapClient: feApp.service?.client,
145
- flpAppId: feApp.app.flpAppId,
146
- startFile: data?.app?.startFile,
147
- localStartFile: data?.app?.localStartFile,
148
- generateIndex: feApp.appOptions?.generateIndex
149
- })
150
- });
156
+ if (isEdmxProjectType) {
157
+ // Add scripts to package.json only for non-CAP projects
158
+ packageJson.scripts = Object.assign(packageJson.scripts ?? {}, {
159
+ ...(0, packageConfig_1.getPackageJsonTasks)({
160
+ localOnly: !feApp.service?.url,
161
+ addMock: !!feApp.service?.metadata,
162
+ addTest,
163
+ sapClient: feApp.service?.client,
164
+ flpAppId: feApp.app.flpAppId,
165
+ startFile: data?.app?.startFile,
166
+ localStartFile: data?.app?.localStartFile,
167
+ generateIndex: feApp.appOptions?.generateIndex
168
+ })
169
+ });
170
+ }
171
+ else {
172
+ // Add deploy-config script for CAP projects
173
+ packageJson.scripts = {
174
+ 'deploy-config': 'npx -p @sap/ux-ui5-tooling fiori add deploy-config cf'
175
+ };
176
+ }
151
177
  fs.writeJSON(packagePath, packageJson);
152
178
  if (addTest) {
153
179
  (0, ui5_test_writer_1.generateOPAFiles)(basePath, {
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": "0.23.2",
4
+ "version": "1.0.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -27,11 +27,12 @@
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.21.1",
31
- "@sap-ux/ui5-application-writer": "0.27.2",
30
+ "@sap-ux/odata-service-writer": "0.22.0",
31
+ "@sap-ux/ui5-application-writer": "1.0.0",
32
32
  "@sap-ux/fe-fpm-writer": "0.25.0",
33
33
  "@sap-ux/ui5-config": "0.23.1",
34
- "@sap-ux/ui5-test-writer": "0.4.0"
34
+ "@sap-ux/ui5-test-writer": "0.4.0",
35
+ "@sap-ux/fiori-generator-shared": "0.3.0"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/ejs": "3.1.2",
@@ -55,11 +55,11 @@
55
55
  };
56
56
  </script>
57
57
 
58
- <script src="../test-resources/sap/ushell/bootstrap/sandbox.js" id="sap-ushell-bootstrap"></script>
58
+ <script src="<%- locals.uShellBootstrapResourceUrl %>" id="sap-ushell-bootstrap"></script>
59
59
  <!-- Bootstrap the UI5 core library. 'data-sap-ui-frameOptions="allow"'' is a NON-SECURE setting for test environments -->
60
60
  <script id="sap-ui-bootstrap"
61
- src="../resources/sap-ui-core.js"
62
- data-sap-ui-libs="<%- ui5.ui5Libs %>"
61
+ src="<%- locals.uiBootstrapResourceUrl %>"
62
+ data-sap-ui-libs="<%= locals.ui5Libs %>"
63
63
  data-sap-ui-async="true"
64
64
  data-sap-ui-preload="async"
65
65
  data-sap-ui-theme="<%- ui5.ui5Theme %>"