@sap-ux/flp-config-sub-generator 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @sap-ux/flp-config-sub-generator
2
+
3
+ ## Features
4
+
5
+ The SAP Fiori Launchpad configuration sub-generator enables users to add Fiori launchpad configuration to SAP Fiori applications
6
+
7
+ ## Installation
8
+
9
+ The SAP Fiori Launchpad configuration sub-generator is installed as part of the [@sap/generator-fiori](https://www.npmjs.com/package/@sap/generator-fiori) generator and cannot be used stand alone. Furthermore, usage requires that the [SAP Fiori Tools Extension](https://marketplace.visualstudio.com/items?itemName=SAPSE.sap-ux-fiori-tools-extension-pack) pack is installed from the VSCode marketplace.
10
+
11
+ ## Launch the SAP Reuse Library sub-generator
12
+
13
+ Open the Command Palette in MS Visual Studio Code ( CMD/CTRL + Shift + P ) and execute the Fiori: Add FLP Embedded Configuration.
14
+
15
+ ## Keywords
16
+ SAP Fiori Generator
@@ -0,0 +1,54 @@
1
+ import Generator from 'yeoman-generator';
2
+ import type { FlpConfigOptions } from './types';
3
+ /**
4
+ * FLP config generator adds an inbound navigation config to an existing manifest.json.
5
+ */
6
+ export default class extends Generator {
7
+ private readonly appWizard;
8
+ private readonly vscode?;
9
+ private readonly launchFlpConfigAsSubGenerator;
10
+ private readonly existingApp;
11
+ private readonly appRootPath;
12
+ private readonly prompts;
13
+ private answers;
14
+ private abort;
15
+ private manifest;
16
+ private manifestPath;
17
+ options: FlpConfigOptions;
18
+ setPromptsCallback: (fn: object) => void;
19
+ /**
20
+ * Constructor for FLP config generator.
21
+ *
22
+ * @param args - arguments passed to the generator
23
+ * @param opts - options passed to the generator
24
+ */
25
+ constructor(args: string | string[], opts: FlpConfigOptions);
26
+ initializing(): Promise<void>;
27
+ prompting(): Promise<void>;
28
+ writing(): Promise<void>;
29
+ /**
30
+ * Updates the manifest and i18n files with the inbound config.
31
+ *
32
+ * @param inboundConfig - the inbound config
33
+ * @param inboundConfig.semanticObject - the semantic object
34
+ * @param inboundConfig.action - the action
35
+ * @param inboundConfig.title - the title
36
+ * @param inboundConfig.subTitle - the subtitle
37
+ * @returns a promise that resolves when the files have been updated
38
+ */
39
+ private _updateFiles;
40
+ /**
41
+ * Update the i18n file. If a i18n.properties file does not exits, it tries to create.
42
+ *
43
+ * @param manifestPath - path to manifest.json
44
+ * @param manifest - parsed content of manifest.json
45
+ * @param titles - the titles to be added to the i18n file
46
+ * @param titles.title - the title to be added to the i18n file
47
+ * @param titles.subTitle - the subtitle to be added to the i18n file
48
+ * @returns true if the i18n file was updated with the key/values
49
+ */
50
+ private _updateI18n;
51
+ end(): Promise<void>;
52
+ }
53
+ export type { FlpConfigOptions };
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = require("path");
7
+ const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
8
+ const logger_1 = __importDefault(require("../utils/logger"));
9
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
10
+ const deploy_config_generator_shared_1 = require("@sap-ux/deploy-config-generator-shared");
11
+ const flp_config_inquirer_1 = require("@sap-ux/flp-config-inquirer");
12
+ const app_config_writer_1 = require("@sap-ux/app-config-writer");
13
+ const project_access_1 = require("@sap-ux/project-access");
14
+ const i18n_1 = require("@sap-ux/i18n");
15
+ const feature_toggle_1 = require("@sap-ux/feature-toggle");
16
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
17
+ const inquirer_common_1 = require("@sap-ux/inquirer-common");
18
+ const constants_1 = require("../utils/constants");
19
+ const utils_1 = require("../utils");
20
+ const prompts_1 = require("../utils/prompts");
21
+ const telemetryEvents_1 = require("../telemetryEvents");
22
+ /**
23
+ * FLP config generator adds an inbound navigation config to an existing manifest.json.
24
+ */
25
+ class default_1 extends yeoman_generator_1.default {
26
+ appWizard;
27
+ vscode;
28
+ launchFlpConfigAsSubGenerator;
29
+ existingApp;
30
+ appRootPath;
31
+ prompts;
32
+ answers;
33
+ abort = false;
34
+ manifest;
35
+ manifestPath;
36
+ options;
37
+ setPromptsCallback;
38
+ /**
39
+ * Constructor for FLP config generator.
40
+ *
41
+ * @param args - arguments passed to the generator
42
+ * @param opts - options passed to the generator
43
+ */
44
+ constructor(args, opts) {
45
+ super(args, opts);
46
+ this.appWizard = opts.appWizard ?? yeoman_ui_types_1.AppWizard.create(opts);
47
+ this.vscode = opts.vscode;
48
+ this.launchFlpConfigAsSubGenerator = opts.launchFlpConfigAsSubGenerator ?? false;
49
+ this.appRootPath = opts.data?.appRootPath ?? opts?.appRootPath ?? this.destinationRoot();
50
+ this.options = opts;
51
+ logger_1.default.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.logWrapper, this.options.logLevel);
52
+ // If launched standalone, set the header, title and description
53
+ if (!this.launchFlpConfigAsSubGenerator) {
54
+ this.appWizard.setHeaderTitle(constants_1.generatorTitle);
55
+ this.prompts = new yeoman_ui_types_1.Prompts((0, prompts_1.getYUIDetails)(this.appRootPath));
56
+ this.setPromptsCallback = (fn) => {
57
+ if (this.prompts) {
58
+ this.prompts.setCallback(fn);
59
+ }
60
+ };
61
+ this.existingApp = true; // generator is launched standalone so app must exist
62
+ }
63
+ }
64
+ async initializing() {
65
+ if (this.env.conflicter) {
66
+ this.env.conflicter.force = this.options.force ?? true;
67
+ }
68
+ await fiori_generator_shared_1.TelemetryHelper.initTelemetrySettings({
69
+ consumerModule: {
70
+ name: '@sap-ux/flp-config-sub-generator',
71
+ version: this.rootGeneratorVersion()
72
+ },
73
+ internalFeature: (0, feature_toggle_1.isInternalFeaturesSettingEnabled)(),
74
+ watchTelemetrySettingStore: false
75
+ });
76
+ if (this.existingApp) {
77
+ this.manifestPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(this.appRootPath), project_access_1.FileName.Manifest);
78
+ this.manifest = this.fs.readJSON(this.manifestPath);
79
+ if (!this.manifest) {
80
+ (0, deploy_config_generator_shared_1.handleErrorMessage)(this.appWizard, (0, utils_1.t)('error.noManifest', { path: this.manifestPath }));
81
+ }
82
+ if (!this.manifest['sap.app']) {
83
+ (0, deploy_config_generator_shared_1.handleErrorMessage)(this.appWizard, (0, utils_1.t)('error.sapNotDefined'));
84
+ }
85
+ }
86
+ }
87
+ async prompting() {
88
+ // FLP answers may already be provided. e.g. headless or LCAP flow.
89
+ if (this.launchFlpConfigAsSubGenerator &&
90
+ this.options.inboundConfig?.semanticObject !== undefined &&
91
+ this.options.inboundConfig?.action !== undefined &&
92
+ this.options.inboundConfig?.title !== undefined &&
93
+ this.options.skipPrompt) {
94
+ this.answers = {
95
+ overwrite: true,
96
+ semanticObject: this.options.inboundConfig.semanticObject,
97
+ action: this.options.inboundConfig.action,
98
+ title: this.options.inboundConfig.title,
99
+ subTitle: this.options.inboundConfig.subTitle
100
+ };
101
+ return;
102
+ }
103
+ // Get existing inbounds
104
+ let inbounds = {};
105
+ if (this.manifest?.['sap.app']?.crossNavigation?.inbounds) {
106
+ inbounds = this.manifest?.['sap.app']?.crossNavigation?.inbounds;
107
+ }
108
+ const silentOverwrite = this.options.overwrite;
109
+ let questions = (await (0, flp_config_inquirer_1.getPrompts)(inbounds, undefined, {
110
+ silentOverwrite,
111
+ inboundId: { hide: true },
112
+ emptyInboundsInfo: { hide: true },
113
+ additionalParameters: { hide: true },
114
+ createAnotherInbound: { hide: true }
115
+ }));
116
+ // Show specific prompt for config update when launched standalone or on CLI. Otherwise it should be handled by consuming generator in YUI.
117
+ if (((0, fiori_generator_shared_1.getHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli || !this.options.launchFlpConfigAsSubGenerator) &&
118
+ this.options.data?.additionalPrompts?.confirmConfigUpdate?.show) {
119
+ const confirmConfigUpdatePrompts = (0, deploy_config_generator_shared_1.getConfirmConfigUpdatePrompt)(this.options.data.additionalPrompts.confirmConfigUpdate.configType);
120
+ questions = (0, inquirer_common_1.withCondition)(questions, (answers) => answers.confirmConfigUpate);
121
+ questions.unshift(...confirmConfigUpdatePrompts);
122
+ }
123
+ this.answers = {};
124
+ const answers = await this.prompt(questions);
125
+ if (answers.s4Continue === false || (answers.overwrite === false && !silentOverwrite)) {
126
+ this.abort = true;
127
+ process.exit(0); // only relevant for CLI
128
+ }
129
+ if (answers.subTitle === '') {
130
+ // '' (empty string) should be set as undefined
131
+ answers.subTitle = undefined;
132
+ }
133
+ Object.assign(this.answers, answers);
134
+ }
135
+ async writing() {
136
+ if (this.abort === false && this.existingApp) {
137
+ await this._updateFiles(this.answers);
138
+ }
139
+ }
140
+ /**
141
+ * Updates the manifest and i18n files with the inbound config.
142
+ *
143
+ * @param inboundConfig - the inbound config
144
+ * @param inboundConfig.semanticObject - the semantic object
145
+ * @param inboundConfig.action - the action
146
+ * @param inboundConfig.title - the title
147
+ * @param inboundConfig.subTitle - the subtitle
148
+ * @returns a promise that resolves when the files have been updated
149
+ */
150
+ async _updateFiles({ semanticObject, action, title, subTitle }) {
151
+ let keysAdded = false;
152
+ if (title) {
153
+ keysAdded = await this._updateI18n(this.manifestPath, this.manifest, {
154
+ title,
155
+ subTitle
156
+ });
157
+ }
158
+ await (0, app_config_writer_1.generateInboundNavigationConfig)(this.appRootPath, {
159
+ semanticObject,
160
+ action,
161
+ title: keysAdded ? `{{${constants_1.i18nKeyTitle}}}` : title,
162
+ subTitle: keysAdded && subTitle ? `{{${constants_1.i18nKeySubTitle}}}` : subTitle
163
+ }, true, this.fs);
164
+ }
165
+ /**
166
+ * Update the i18n file. If a i18n.properties file does not exits, it tries to create.
167
+ *
168
+ * @param manifestPath - path to manifest.json
169
+ * @param manifest - parsed content of manifest.json
170
+ * @param titles - the titles to be added to the i18n file
171
+ * @param titles.title - the title to be added to the i18n file
172
+ * @param titles.subTitle - the subtitle to be added to the i18n file
173
+ * @returns true if the i18n file was updated with the key/values
174
+ */
175
+ async _updateI18n(manifestPath, manifest, { title, subTitle }) {
176
+ let createProps = false;
177
+ const { 'sap.app': i18nPath } = await (0, project_access_1.getI18nPropertiesPaths)(manifestPath, manifest);
178
+ try {
179
+ const i18nEntries = [{ key: constants_1.i18nKeyTitle, value: title }];
180
+ if (subTitle) {
181
+ i18nEntries.push({ key: constants_1.i18nKeySubTitle, value: subTitle });
182
+ }
183
+ createProps = await (0, i18n_1.createPropertiesI18nEntries)(i18nPath, i18nEntries, this.appRootPath, this.fs);
184
+ }
185
+ catch (error) {
186
+ const errorMsg = (0, utils_1.t)('warning.updatei18n', { path: i18nPath });
187
+ this.appWizard.showWarning(errorMsg, yeoman_ui_types_1.MessageType.notification);
188
+ logger_1.default.logger?.error(errorMsg);
189
+ }
190
+ return createProps;
191
+ }
192
+ async end() {
193
+ // The app would not have been generated until after the writing phase due to the current ordering of the composeWith from Fiori generators
194
+ if (this.abort === false && !this.existingApp) {
195
+ this.manifestPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(this.appRootPath), project_access_1.FileName.Manifest);
196
+ this.manifest = this.fs.readJSON(this.manifestPath);
197
+ await this._updateFiles(this.answers);
198
+ }
199
+ try {
200
+ if (!this.options.launchFlpConfigAsSubGenerator &&
201
+ (0, fiori_generator_shared_1.isExtensionInstalled)(this.vscode, fiori_generator_shared_1.YUI_EXTENSION_ID, fiori_generator_shared_1.YUI_MIN_VER_FILES_GENERATED_MSG)) {
202
+ this.appWizard?.showInformation((0, utils_1.t)('info.filesGenerated'), yeoman_ui_types_1.MessageType.notification);
203
+ }
204
+ (0, fiori_generator_shared_1.sendTelemetry)(telemetryEvents_1.EventName.GENERATION_SUCCESS, fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
205
+ appType: 'flp-config',
206
+ ...this.options.telemetryData
207
+ }) ?? {}).catch((error) => {
208
+ logger_1.default.logger.error((0, utils_1.t)('error.telemetry', { error }));
209
+ });
210
+ }
211
+ catch (error) {
212
+ logger_1.default.logger?.error((0, utils_1.t)('error.endPhase', { error }));
213
+ }
214
+ }
215
+ }
216
+ exports.default = default_1;
217
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,74 @@
1
+ import type Generator from 'yeoman-generator';
2
+ import type { AppWizard } from '@sap-devx/yeoman-ui-types';
3
+ import type { VSCodeInstance, TelemetryData, LogWrapper } from '@sap-ux/fiori-generator-shared';
4
+ import type { ManifestNamespace } from '@sap-ux/project-access';
5
+ export interface FlpConfigOptions extends Generator.GeneratorOptions {
6
+ /**
7
+ * VSCode instance
8
+ */
9
+ vscode?: VSCodeInstance;
10
+ /**
11
+ * AppWizard instance
12
+ */
13
+ appWizard?: AppWizard;
14
+ /**
15
+ * Whether the generator is launched as a subgenerator
16
+ */
17
+ launchFlpConfigAsSubGenerator?: boolean;
18
+ /**
19
+ * Path to the application root where the Fiori launchpad configuration will be added.
20
+ */
21
+ appRootPath?: string;
22
+ /**
23
+ * Skips the prompting phase
24
+ */
25
+ skipPrompt?: boolean;
26
+ /**
27
+ * FLP configuration answers
28
+ */
29
+ inboundConfig: Partial<ManifestNamespace.Inbound[string]>;
30
+ /**
31
+ * Option to force the conflicter property of the yeoman environment (prevents additional prompt for overwriting files)
32
+ */
33
+ force?: boolean;
34
+ /**
35
+ * Telemetry data to be send after deployment configuration has been added
36
+ */
37
+ telemetryData?: TelemetryData;
38
+ /**
39
+ * Option to overwrite existing configuration without prompting
40
+ */
41
+ overwrite?: boolean;
42
+ /**
43
+ * Data which may be passed from external sources e.g extensions like Application modeler
44
+ */
45
+ data?: {
46
+ /**
47
+ * Path to the application root where the Fiori launchpad configuration will be added.
48
+ */
49
+ appRootPath?: string;
50
+ /**
51
+ * Config for additional prompts
52
+ */
53
+ additionalPrompts?: {
54
+ /**
55
+ * Prompt to confirm the the update of non-productive configurations as they are centrally managed as part of the CI pipeline.
56
+ */
57
+ confirmConfigUpdate?: {
58
+ /**
59
+ * Whether the prompt should be shown.
60
+ */
61
+ show?: boolean;
62
+ /**
63
+ * The type of configuration being updated. This will be added to the start of the prompt message.
64
+ */
65
+ configType?: string;
66
+ };
67
+ };
68
+ };
69
+ /**
70
+ * Logger instance
71
+ */
72
+ logWrapper?: LogWrapper;
73
+ }
74
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Event names for telemetry for the FLP config generator
3
+ */
4
+ export declare enum EventName {
5
+ GENERATION_SUCCESS = "GENERATION_SUCCESS"
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventName = void 0;
4
+ /**
5
+ * Event names for telemetry for the FLP config generator
6
+ */
7
+ var EventName;
8
+ (function (EventName) {
9
+ EventName["GENERATION_SUCCESS"] = "GENERATION_SUCCESS";
10
+ })(EventName || (exports.EventName = EventName = {}));
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ {
2
+ "error": {
3
+ "endPhase": "Error end phase deployment-generator:flp: {{- error}}",
4
+ "telemetry": "Failed to send telemetry data after FLP configuration has been added. {{- error}}",
5
+ "noManifest": "Manifest not found at path: {{- path}}",
6
+ "sapNotDefined": "Manifest is missing required section 'sap.app'"
7
+ },
8
+ "warning": {
9
+ "updatei18n": "Cannot update i18n properties file: {{- path}}"
10
+ },
11
+ "info": {
12
+ "filesGenerated": "The files have been generated."
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ export declare const i18nKeyTitle = "flpTitle";
2
+ export declare const i18nKeySubTitle = "flpSubtitle";
3
+ export declare const generatorTitle = "Fiori Launchpad Configuration Generator";
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatorTitle = exports.i18nKeySubTitle = exports.i18nKeyTitle = void 0;
4
+ exports.i18nKeyTitle = 'flpTitle';
5
+ exports.i18nKeySubTitle = 'flpSubtitle';
6
+ exports.generatorTitle = 'Fiori Launchpad Configuration Generator';
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,14 @@
1
+ import type { TOptions } from 'i18next';
2
+ /**
3
+ * Initialize i18next with the translations for this module.
4
+ */
5
+ export declare function initI18n(): Promise<void>;
6
+ /**
7
+ * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
8
+ *
9
+ * @param key i18n key
10
+ * @param options additional options
11
+ * @returns {string} localized string stored for the given key
12
+ */
13
+ export declare function t(key: string, options?: TOptions): string;
14
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.t = exports.initI18n = void 0;
7
+ const i18next_1 = __importDefault(require("i18next"));
8
+ const flp_config_sub_generator_i18n_json_1 = __importDefault(require("../translations/flp-config-sub-generator.i18n.json"));
9
+ const ui5LibGeneratorNs = 'ui5-lib-generator';
10
+ /**
11
+ * Initialize i18next with the translations for this module.
12
+ */
13
+ async function initI18n() {
14
+ await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', ui5LibGeneratorNs, flp_config_sub_generator_i18n_json_1.default));
15
+ }
16
+ exports.initI18n = initI18n;
17
+ /**
18
+ * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
19
+ *
20
+ * @param key i18n key
21
+ * @param options additional options
22
+ * @returns {string} localized string stored for the given key
23
+ */
24
+ function t(key, options) {
25
+ if (!options?.ns) {
26
+ options = Object.assign(options ?? {}, { ns: ui5LibGeneratorNs });
27
+ }
28
+ return i18next_1.default.t(key, options);
29
+ }
30
+ exports.t = t;
31
+ initI18n().catch(() => {
32
+ // Needed for lint
33
+ });
34
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1,2 @@
1
+ export * from './i18n';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./i18n"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,32 @@
1
+ import { type ILogWrapper } from '@sap-ux/fiori-generator-shared';
2
+ import type { Logger } from 'yeoman-environment';
3
+ import type { IVSCodeExtLogger, LogLevel } from '@vscode-logging/logger';
4
+ /**
5
+ * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
6
+ */
7
+ export default class FlpGenLogger {
8
+ private static _logger;
9
+ /**
10
+ * Get the logger.
11
+ *
12
+ * @returns the logger
13
+ */
14
+ static get logger(): ILogWrapper;
15
+ /**
16
+ * Set the logger.
17
+ *
18
+ * @param value the logger to set
19
+ */
20
+ static set logger(value: ILogWrapper);
21
+ /**
22
+ * Configures the vscode logger.
23
+ *
24
+ * @param vscLogger - the vscode logger
25
+ * @param loggerName - the logger name
26
+ * @param yoLogger - the yeoman logger
27
+ * @param vscode - the vscode instance
28
+ * @param logLevel - the log level
29
+ */
30
+ static configureLogging(vscLogger: IVSCodeExtLogger, loggerName: string, yoLogger: Logger, vscode?: unknown, logLevel?: LogLevel): void;
31
+ }
32
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
4
+ /**
5
+ * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
6
+ */
7
+ class FlpGenLogger {
8
+ static _logger = fiori_generator_shared_1.DefaultLogger;
9
+ /**
10
+ * Get the logger.
11
+ *
12
+ * @returns the logger
13
+ */
14
+ static get logger() {
15
+ return FlpGenLogger._logger;
16
+ }
17
+ /**
18
+ * Set the logger.
19
+ *
20
+ * @param value the logger to set
21
+ */
22
+ static set logger(value) {
23
+ FlpGenLogger._logger = value;
24
+ }
25
+ /**
26
+ * Configures the vscode logger.
27
+ *
28
+ * @param vscLogger - the vscode logger
29
+ * @param loggerName - the logger name
30
+ * @param yoLogger - the yeoman logger
31
+ * @param vscode - the vscode instance
32
+ * @param logLevel - the log level
33
+ */
34
+ static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel) {
35
+ const logWrapper = new fiori_generator_shared_1.LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
36
+ FlpGenLogger.logger = logWrapper;
37
+ }
38
+ }
39
+ exports.default = FlpGenLogger;
40
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Returns the details for the YUI prompt.
3
+ *
4
+ * @param appRootPath - path to the application to be displayed in YUI step description
5
+ * @returns step details
6
+ */
7
+ export declare function getYUIDetails(appRootPath: string): {
8
+ name: string;
9
+ description: string;
10
+ }[];
11
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getYUIDetails = void 0;
4
+ const path_1 = require("path");
5
+ /**
6
+ * Returns the details for the YUI prompt.
7
+ *
8
+ * @param appRootPath - path to the application to be displayed in YUI step description
9
+ * @returns step details
10
+ */
11
+ function getYUIDetails(appRootPath) {
12
+ return [
13
+ {
14
+ name: 'Fiori Launchpad Configuration',
15
+ description: `Configure Fiori Launchpad settings - ${(0, path_1.basename)(appRootPath)}`
16
+ }
17
+ ];
18
+ }
19
+ exports.getYUIDetails = getYUIDetails;
20
+ //# sourceMappingURL=prompts.js.map
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@sap-ux/flp-config-sub-generator",
3
+ "description": "Generator for creating Fiori Launcpad configuration",
4
+ "version": "0.0.1",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/SAP/open-ux-tools.git",
8
+ "directory": "packages/flp-config-sub-generator"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "main": "generators/app/index.js",
15
+ "files": [
16
+ "LICENSE",
17
+ "generators",
18
+ "!generators/*.map",
19
+ "!generators/**/*.map"
20
+ ],
21
+ "dependencies": {
22
+ "@sap-devx/yeoman-ui-types": "1.14.4",
23
+ "i18next": "23.5.1",
24
+ "inquirer": "8.2.6",
25
+ "yeoman-generator": "5.10.0",
26
+ "@sap-ux/app-config-writer": "0.5.9",
27
+ "@sap-ux/deploy-config-generator-shared": "0.0.9",
28
+ "@sap-ux/feature-toggle": "0.2.3",
29
+ "@sap-ux/fiori-generator-shared": "0.7.18",
30
+ "@sap-ux/flp-config-inquirer": "0.2.6",
31
+ "@sap-ux/i18n": "0.2.0",
32
+ "@sap-ux/inquirer-common": "0.6.1",
33
+ "@sap-ux/project-access": "1.28.10"
34
+ },
35
+ "devDependencies": {
36
+ "@jest/types": "29.6.3",
37
+ "@types/inquirer": "8.2.6",
38
+ "@types/mem-fs": "1.1.2",
39
+ "@types/mem-fs-editor": "7.0.1",
40
+ "@types/yeoman-generator": "5.2.11",
41
+ "@types/yeoman-environment": "2.10.11",
42
+ "@types/yeoman-test": "4.0.6",
43
+ "@vscode-logging/logger": "2.0.0",
44
+ "memfs": "3.4.13",
45
+ "mem-fs-editor": "9.4.0",
46
+ "lodash": "4.17.21",
47
+ "@types/lodash": "4.14.202",
48
+ "rimraf": "5.0.5",
49
+ "typescript": "5.3.3",
50
+ "unionfs": "4.4.0",
51
+ "yeoman-test": "6.3.0",
52
+ "@sap-ux/nodejs-utils": "0.1.4"
53
+ },
54
+ "engines": {
55
+ "node": ">=18.x"
56
+ },
57
+ "scripts": {
58
+ "build": "tsc --build",
59
+ "clean": "rimraf --glob generators test/test-output coverage *.tsbuildinfo",
60
+ "watch": "tsc --watch",
61
+ "lint": "eslint . --ext .ts",
62
+ "lint:fix": "eslint . --ext .ts --fix",
63
+ "test": "jest --ci --forceExit --detectOpenHandles --colors --passWithNoTests",
64
+ "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
65
+ "link": "pnpm link --global",
66
+ "unlink": "pnpm unlink --global"
67
+ }
68
+ }