@sap-ux/preview-middleware 0.26.11 → 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.
- package/dist/base/cdm.d.ts +2 -2
- package/dist/base/cdm.js +10 -11
- package/dist/base/config.d.ts +1 -1
- package/dist/base/config.js +60 -72
- package/dist/base/flex.js +16 -23
- package/dist/base/flp.d.ts +2 -2
- package/dist/base/flp.js +96 -96
- package/dist/base/index.d.ts +3 -3
- package/dist/base/index.js +3 -12
- package/dist/base/remote-url.js +14 -24
- package/dist/base/test.d.ts +1 -1
- package/dist/base/test.js +2 -6
- package/dist/base/utils/cards.d.ts +1 -1
- package/dist/base/utils/cards.js +3 -9
- package/dist/client/adp/add-fragment.js +4 -4
- package/dist/client/adp/add-fragment.ts +2 -2
- package/dist/client/adp/api-handler.js +2 -2
- package/dist/client/adp/api-handler.ts +1 -1
- package/dist/client/adp/command-executor.js +3 -3
- package/dist/client/adp/command-executor.ts +2 -2
- package/dist/client/adp/controllers/AddActionFragment.controller.js +5 -5
- package/dist/client/adp/controllers/AddActionFragment.controller.ts +7 -7
- package/dist/client/adp/controllers/AddCustomFragment.controller.js +7 -7
- package/dist/client/adp/controllers/AddCustomFragment.controller.ts +9 -9
- package/dist/client/adp/controllers/AddFragment.controller.js +7 -7
- package/dist/client/adp/controllers/AddFragment.controller.ts +11 -11
- package/dist/client/adp/controllers/AddSubpage.controller.js +4 -4
- package/dist/client/adp/controllers/AddSubpage.controller.ts +7 -7
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +7 -7
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +11 -11
- package/dist/client/adp/controllers/BaseDialog.controller.js +3 -3
- package/dist/client/adp/controllers/BaseDialog.controller.ts +6 -6
- package/dist/client/adp/controllers/ControllerExtension.controller.js +14 -14
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +12 -12
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +4 -4
- package/dist/client/adp/controllers/ExtensionPoint.controller.ts +5 -5
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +2 -2
- package/dist/client/adp/controllers/FileExistsDialog.controller.ts +2 -2
- package/dist/client/adp/dialog-factory.js +2 -2
- package/dist/client/adp/dialog-factory.ts +16 -16
- package/dist/client/adp/extend-controller.js +4 -4
- package/dist/client/adp/extend-controller.ts +2 -2
- package/dist/client/adp/extension-point.js +5 -5
- package/dist/client/adp/extension-point.ts +4 -4
- package/dist/client/adp/init-dialogs.js +6 -6
- package/dist/client/adp/init-dialogs.ts +6 -6
- package/dist/client/adp/init.js +13 -13
- package/dist/client/adp/init.ts +9 -9
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +8 -8
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.ts +10 -10
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +13 -13
- package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +11 -11
- package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +11 -11
- package/dist/client/adp/quick-actions/common/add-new-annotation-file.ts +10 -10
- package/dist/client/adp/quick-actions/common/create-page-action.js +8 -8
- package/dist/client/adp/quick-actions/common/create-page-action.ts +7 -7
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +6 -6
- package/dist/client/adp/quick-actions/common/op-add-custom-section.ts +5 -5
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +7 -7
- package/dist/client/adp/quick-actions/common/op-add-header-field.ts +7 -7
- package/dist/client/adp/quick-actions/common/utils.ts +1 -1
- package/dist/client/adp/quick-actions/dialog-enablement-validator.js +3 -3
- package/dist/client/adp/quick-actions/dialog-enablement-validator.ts +3 -3
- package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +6 -6
- package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +5 -5
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +7 -7
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +11 -11
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +13 -13
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.ts +7 -7
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +9 -9
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +11 -11
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.ts +3 -3
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.ts +4 -4
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +12 -12
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.ts +8 -8
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +6 -6
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/registry.js +18 -18
- package/dist/client/adp/quick-actions/fe-v2/registry.ts +18 -18
- package/dist/client/adp/quick-actions/fe-v2/utils.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/utils.ts +2 -2
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +7 -7
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +9 -9
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.ts +7 -7
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +6 -6
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v4/create-page-action.js +11 -11
- package/dist/client/adp/quick-actions/fe-v4/create-page-action.ts +9 -9
- package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.js +13 -13
- package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.ts +11 -11
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.js +16 -16
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.ts +9 -9
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +5 -5
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.ts +4 -4
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +5 -5
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +7 -7
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +5 -5
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.js +8 -8
- package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.ts +8 -8
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +12 -12
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.ts +8 -8
- package/dist/client/adp/quick-actions/fe-v4/registry.js +17 -17
- package/dist/client/adp/quick-actions/fe-v4/registry.ts +17 -17
- package/dist/client/adp/quick-actions/fe-v4/utils.js +6 -6
- package/dist/client/adp/quick-actions/fe-v4/utils.ts +3 -3
- package/dist/client/adp/quick-actions/load.ts +2 -2
- package/dist/client/adp/quick-actions/quick-action-base.js +2 -2
- package/dist/client/adp/quick-actions/quick-action-base.ts +3 -3
- package/dist/client/adp/quick-actions/simple-quick-action-base.js +3 -3
- package/dist/client/adp/quick-actions/simple-quick-action-base.ts +4 -4
- package/dist/client/adp/quick-actions/table-quick-action-base.js +17 -17
- package/dist/client/adp/quick-actions/table-quick-action-base.ts +9 -9
- package/dist/client/adp/sync-views-utils.js +4 -4
- package/dist/client/adp/sync-views-utils.ts +3 -3
- package/dist/client/adp/utils.js +3 -3
- package/dist/client/adp/utils.ts +2 -2
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +7 -7
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +2 -2
- package/dist/client/cpe/changes/flex-change.js +3 -3
- package/dist/client/cpe/changes/flex-change.ts +3 -3
- package/dist/client/cpe/changes/generic-change.js +5 -5
- package/dist/client/cpe/changes/generic-change.ts +4 -4
- package/dist/client/cpe/changes/index.js +2 -2
- package/dist/client/cpe/changes/index.ts +1 -1
- package/dist/client/cpe/changes/service.js +12 -12
- package/dist/client/cpe/changes/service.ts +9 -9
- package/dist/client/cpe/changes/validator.js +2 -2
- package/dist/client/cpe/changes/validator.ts +1 -1
- package/dist/client/cpe/communication-service.js +2 -2
- package/dist/client/cpe/communication-service.ts +2 -2
- package/dist/client/cpe/connector-service.js +3 -3
- package/dist/client/cpe/connector-service.ts +3 -3
- package/dist/client/cpe/context-menu-service.js +6 -6
- package/dist/client/cpe/context-menu-service.ts +6 -6
- package/dist/client/cpe/control-data.js +3 -3
- package/dist/client/cpe/control-data.ts +5 -5
- package/dist/client/cpe/documentation.js +4 -4
- package/dist/client/cpe/documentation.ts +5 -5
- package/dist/client/cpe/init.js +15 -15
- package/dist/client/cpe/init.ts +16 -16
- package/dist/client/cpe/odata-health/odata-health-checker.js +5 -5
- package/dist/client/cpe/odata-health/odata-health-checker.ts +10 -10
- package/dist/client/cpe/outline/editable.js +4 -4
- package/dist/client/cpe/outline/editable.ts +4 -4
- package/dist/client/cpe/outline/nodes.js +7 -7
- package/dist/client/cpe/outline/nodes.ts +7 -7
- package/dist/client/cpe/outline/service.js +3 -3
- package/dist/client/cpe/outline/service.ts +4 -4
- package/dist/client/cpe/quick-actions/quick-action-service.js +5 -5
- package/dist/client/cpe/quick-actions/quick-action-service.ts +10 -10
- package/dist/client/cpe/quick-actions/registry.js +3 -3
- package/dist/client/cpe/quick-actions/registry.ts +4 -4
- package/dist/client/cpe/quick-actions/utils.js +3 -3
- package/dist/client/cpe/quick-actions/utils.ts +2 -2
- package/dist/client/cpe/rta-service.ts +1 -1
- package/dist/client/cpe/selection.js +8 -8
- package/dist/client/cpe/selection.ts +7 -7
- package/dist/client/cpe/utils.js +2 -2
- package/dist/client/cpe/utils.ts +2 -2
- package/dist/client/flp/WorkspaceConnector.js +6 -6
- package/dist/client/flp/WorkspaceConnector.ts +4 -4
- package/dist/client/flp/enableFakeConnector.js +4 -4
- package/dist/client/flp/enableFakeConnector.ts +3 -3
- package/dist/client/flp/init.js +6 -6
- package/dist/client/flp/init.ts +5 -5
- package/dist/client/flp/initConnectors.js +3 -3
- package/dist/client/flp/initConnectors.ts +1 -1
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +397 -477
- package/dist/client/utils/additional-change-info.js +2 -2
- package/dist/client/utils/additional-change-info.ts +2 -2
- package/dist/client/utils/core.js +2 -2
- package/dist/client/utils/core.ts +1 -1
- package/dist/client/utils/fe-v4.js +3 -3
- package/dist/client/utils/fe-v4.ts +2 -2
- package/dist/client/utils/info-center-message.js +3 -3
- package/dist/client/utils/info-center-message.ts +2 -2
- package/dist/client/utils/version.js +2 -2
- package/dist/client/utils/version.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -25
- package/dist/types/index.js +1 -4
- package/dist/ui5/middleware.d.ts +11 -1
- package/dist/ui5/middleware.js +13 -15
- package/package.json +18 -16
package/dist/base/flp.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { create as createStorage } from 'mem-fs';
|
|
2
|
+
import { create } from 'mem-fs-editor';
|
|
3
|
+
import { render } from 'ejs';
|
|
4
|
+
import { Router as createRouter, static as serveStatic, json } from 'express';
|
|
5
|
+
import { dirname, join, posix } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
import { getWebappPath, getProjectType, findProjectRoot, FileName, createApplicationAccess } from '@sap-ux/project-access';
|
|
11
|
+
import { AdpPreview, loadAppVariant, readManifestFromBuildPath } from '@sap-ux/adp-tooling';
|
|
12
|
+
import { isAppStudio, exposePort } from '@sap-ux/btp-utils';
|
|
13
|
+
import { FeatureToggleAccess } from '@sap-ux/feature-toggle';
|
|
14
|
+
import { deleteChange, readChanges, readLocalModulePaths, stripLocalModulesFromLrepResponse, writeChange } from './flex.js';
|
|
15
|
+
import { generateImportList, mergeTestConfigDefaults } from './test.js';
|
|
16
|
+
import { getFlpConfigWithDefaults, createFlpTemplateConfig, PREVIEW_URL, isFlexConnector, createTestTemplateConfig, addApp, getAppName, sanitizeRtaConfig, CARD_GENERATOR_DEFAULT, remapResourcesForPath } from './config.js';
|
|
17
|
+
import { generateCdm } from './cdm.js';
|
|
18
|
+
import { readFileSync } from 'node:fs';
|
|
19
|
+
import { getIntegrationCard } from './utils/cards.js';
|
|
20
|
+
import { createPropertiesI18nEntries } from '@sap-ux/i18n';
|
|
21
|
+
import { AdaptationProjectType } from '@sap-ux/axios-extension';
|
|
21
22
|
const DEFAULT_LIVERELOAD_PORT = 35729;
|
|
22
23
|
/**
|
|
23
24
|
* Class handling preview of a sandbox FLP.
|
|
24
25
|
*/
|
|
25
|
-
class FlpSandbox {
|
|
26
|
+
export class FlpSandbox {
|
|
26
27
|
adp;
|
|
27
28
|
manifest;
|
|
28
29
|
onChangeRequest;
|
|
@@ -46,15 +47,15 @@ class FlpSandbox {
|
|
|
46
47
|
* @param logger logger instance
|
|
47
48
|
*/
|
|
48
49
|
constructor(config, project, utils, logger) {
|
|
49
|
-
this.fs =
|
|
50
|
+
this.fs = create(createStorage());
|
|
50
51
|
this.logger = logger;
|
|
51
52
|
this.project = project;
|
|
52
53
|
this.utils = utils;
|
|
53
|
-
this.flpConfig =
|
|
54
|
+
this.flpConfig = getFlpConfigWithDefaults(config.flp);
|
|
54
55
|
this.test = config.test;
|
|
55
|
-
this.rta = config.editors?.rta ??
|
|
56
|
+
this.rta = config.editors?.rta ?? sanitizeRtaConfig(config.rta, logger); //NOSONAR
|
|
56
57
|
logger.debug(`Config: ${JSON.stringify({ flp: this.flpConfig, rta: this.rta, test: this.test })}`);
|
|
57
|
-
this.router = (
|
|
58
|
+
this.router = createRouter();
|
|
58
59
|
this.cardGenerator = config.editors?.cardGenerator;
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
@@ -74,15 +75,15 @@ class FlpSandbox {
|
|
|
74
75
|
* @param adp optional reference to the ADP tooling
|
|
75
76
|
*/
|
|
76
77
|
async init(manifest, componentId, resources = {}, adp) {
|
|
77
|
-
const projectRoot = await
|
|
78
|
-
this.projectType = await
|
|
78
|
+
const projectRoot = await findProjectRoot(process.cwd(), false, true);
|
|
79
|
+
this.projectType = await getProjectType(projectRoot);
|
|
79
80
|
this.createFlexHandler();
|
|
80
81
|
this.flpConfig.libs ??= await this.hasLocateReuseLibsScript();
|
|
81
82
|
const id = manifest['sap.app']?.id ?? '';
|
|
82
|
-
this.templateConfig =
|
|
83
|
+
this.templateConfig = createFlpTemplateConfig(this.flpConfig, manifest, resources);
|
|
83
84
|
this.adp = adp;
|
|
84
85
|
this.manifest = manifest;
|
|
85
|
-
await
|
|
86
|
+
await addApp(this.templateConfig, manifest, {
|
|
86
87
|
componentId,
|
|
87
88
|
target: resources[componentId ?? id] ?? this.templateConfig.basePath,
|
|
88
89
|
local: '.',
|
|
@@ -158,7 +159,7 @@ class FlpSandbox {
|
|
|
158
159
|
*/
|
|
159
160
|
checkDeleteConnectors(ui5VersionMajor, ui5VersionMinor, isCDN) {
|
|
160
161
|
if (ui5VersionMajor === 1 && ui5VersionMinor < 84) {
|
|
161
|
-
this.templateConfig.ui5.flex = this.templateConfig.ui5?.flex?.filter((connector) =>
|
|
162
|
+
this.templateConfig.ui5.flex = this.templateConfig.ui5?.flex?.filter((connector) => isFlexConnector(connector));
|
|
162
163
|
this.logger.debug(`The Fiori Tools local connector (WorkspaceConnector) is not being used because the current UI5 version does not support it.${isCDN ? 'The Fiori Tools fake connector (FakeLrepConnector) will be used instead.' : ''} `);
|
|
163
164
|
if (!isCDN) {
|
|
164
165
|
this.logger.warn(`The preview with virtual endpoints does not support flex changes for the current UI5 version ${ui5VersionMajor}.${ui5VersionMinor} from npmjs. Consider using a proxy to load UI5 resources from the CDN (e.g., https://ui5.sap.com), or upgrade the UI5 version in the yaml configuration to at least 1.84.`);
|
|
@@ -168,8 +169,8 @@ class FlpSandbox {
|
|
|
168
169
|
this.logger.debug(`The Fiori Tools local connector (WorkspaceConnector) is being used.`);
|
|
169
170
|
}
|
|
170
171
|
if (this.projectType === 'CAPJava' || this.projectType === 'CAPNodejs') {
|
|
171
|
-
this.templateConfig.ui5.flex = this.templateConfig.ui5?.flex?.filter((connector) => !
|
|
172
|
-
(
|
|
172
|
+
this.templateConfig.ui5.flex = this.templateConfig.ui5?.flex?.filter((connector) => !isFlexConnector(connector) ||
|
|
173
|
+
(isFlexConnector(connector) && !connector.url?.startsWith('/sap/bc/lrep')));
|
|
173
174
|
this.logger.debug(`The ABAP connector is not being used because the current project type is '${this.projectType}'.`);
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
@@ -213,10 +214,10 @@ class FlpSandbox {
|
|
|
213
214
|
developerMode: editor.developerMode === true,
|
|
214
215
|
pluginScript: editor.pluginScript
|
|
215
216
|
};
|
|
216
|
-
config.features =
|
|
217
|
+
config.features = FeatureToggleAccess.getAllFeatureToggles();
|
|
217
218
|
const appId = this.manifest['sap.app']?.id ?? '';
|
|
218
|
-
|
|
219
|
-
return
|
|
219
|
+
remapResourcesForPath(config, editor.path, appId);
|
|
220
|
+
return render(this.getSandboxTemplate(ui5Version), config);
|
|
220
221
|
}
|
|
221
222
|
/**
|
|
222
223
|
* Sets application dependencies in the template configuration.
|
|
@@ -227,7 +228,7 @@ class FlpSandbox {
|
|
|
227
228
|
async setApplicationDependencies() {
|
|
228
229
|
if (this.adp) {
|
|
229
230
|
await this.adp.sync();
|
|
230
|
-
const appName =
|
|
231
|
+
const appName = getAppName(this.manifest, this.flpConfig.intent);
|
|
231
232
|
this.templateConfig.apps[appName].applicationDependencies = this.adp.descriptor;
|
|
232
233
|
}
|
|
233
234
|
}
|
|
@@ -246,13 +247,13 @@ class FlpSandbox {
|
|
|
246
247
|
if (scenario === 'ADAPTATION_PROJECT') {
|
|
247
248
|
templatePreviewUrl = templatePreviewUrl.replace('?', `?sap-ui-layer=${rta.layer}&`);
|
|
248
249
|
}
|
|
249
|
-
const template =
|
|
250
|
-
const features =
|
|
250
|
+
const template = readFileSync(join(__dirname, '../../templates/flp/editor.ejs'), 'utf-8');
|
|
251
|
+
const features = FeatureToggleAccess.getAllFeatureToggles();
|
|
251
252
|
const envPort = process.env.FIORI_TOOLS_LIVERELOAD_PORT;
|
|
252
253
|
let livereloadPort = envPort ? Number.parseInt(envPort, 10) : DEFAULT_LIVERELOAD_PORT;
|
|
253
254
|
livereloadPort = Number.isNaN(livereloadPort) ? DEFAULT_LIVERELOAD_PORT : livereloadPort;
|
|
254
|
-
const envLivereloadUrl =
|
|
255
|
-
const html =
|
|
255
|
+
const envLivereloadUrl = isAppStudio() ? await exposePort(livereloadPort) : undefined;
|
|
256
|
+
const html = render(template, {
|
|
256
257
|
previewUrl: templatePreviewUrl,
|
|
257
258
|
telemetry: !!rta.options?.telemetry,
|
|
258
259
|
appName: rta.options?.appName,
|
|
@@ -278,7 +279,7 @@ class FlpSandbox {
|
|
|
278
279
|
if (!req.query['fiori-tools-rta-mode']) {
|
|
279
280
|
this.logger.debug(`Adjusting URL parameters for runtime adaptation mode. Redirecting to correct URL.`);
|
|
280
281
|
const url = 'ui5-patched-router' in req
|
|
281
|
-
?
|
|
282
|
+
? posix.join(req['ui5-patched-router']?.baseUrl ?? '', previewUrl)
|
|
282
283
|
: previewUrl;
|
|
283
284
|
const params = structuredClone(req.query);
|
|
284
285
|
params['sap-ui-xx-viewCache'] = 'false';
|
|
@@ -298,7 +299,7 @@ class FlpSandbox {
|
|
|
298
299
|
* @param rta runtime authoring configuration
|
|
299
300
|
*/
|
|
300
301
|
addEditorRoutes(rta) {
|
|
301
|
-
const cpe =
|
|
302
|
+
const cpe = dirname(require.resolve('@sap-ux/control-property-editor-sources'));
|
|
302
303
|
for (const editor of rta.endpoints) {
|
|
303
304
|
let previewUrl = editor.path.startsWith('/') ? editor.path : `/${editor.path}`;
|
|
304
305
|
if (editor.developerMode) {
|
|
@@ -307,11 +308,11 @@ class FlpSandbox {
|
|
|
307
308
|
this.router.get(editor.path, async (req, res) => {
|
|
308
309
|
await this.editorGetHandlerDeveloperMode(req, res, rta, previewUrl);
|
|
309
310
|
});
|
|
310
|
-
let path =
|
|
311
|
+
let path = dirname(editor.path);
|
|
311
312
|
if (!path.endsWith('/')) {
|
|
312
313
|
path = `${path}/`;
|
|
313
314
|
}
|
|
314
|
-
this.router.use(`${path}editor`, (
|
|
315
|
+
this.router.use(`${path}editor`, serveStatic(cpe));
|
|
315
316
|
}
|
|
316
317
|
this.router.get(previewUrl, async (req, res) => {
|
|
317
318
|
await this.editorGetHandler(req, res, rta, previewUrl, editor);
|
|
@@ -330,7 +331,7 @@ class FlpSandbox {
|
|
|
330
331
|
// connect API (karma test runner) has no request query property
|
|
331
332
|
if ('query' in req && 'redirect' in res && !req.query['sap-ui-xx-viewCache']) {
|
|
332
333
|
this.logger.debug(`Adjusting URL parameters for preview. Redirecting to correct URL.`);
|
|
333
|
-
const url = 'ui5-patched-router' in req ?
|
|
334
|
+
const url = 'ui5-patched-router' in req ? posix.join(req['ui5-patched-router']?.baseUrl ?? '', req.path) : req.path;
|
|
334
335
|
const params = structuredClone(req.query);
|
|
335
336
|
params['sap-ui-xx-viewCache'] = 'false';
|
|
336
337
|
const redirectUrl = new URL(`${url}?${new URLSearchParams(params)}`, 'http://localhost');
|
|
@@ -359,7 +360,7 @@ class FlpSandbox {
|
|
|
359
360
|
this.removeFlexExtensionPointEnabled();
|
|
360
361
|
}
|
|
361
362
|
//for consistency reasons, we also add the baseUrl to the HTML here, although it is only used in editor mode
|
|
362
|
-
const html =
|
|
363
|
+
const html = render(this.getSandboxTemplate(ui5Version), this.templateConfig);
|
|
363
364
|
this.sendResponse(res, 'text/html', 200, html);
|
|
364
365
|
}
|
|
365
366
|
}
|
|
@@ -368,7 +369,7 @@ class FlpSandbox {
|
|
|
368
369
|
*/
|
|
369
370
|
addStandardRoutes() {
|
|
370
371
|
// register static client sources
|
|
371
|
-
this.router.use(
|
|
372
|
+
this.router.use(PREVIEW_URL.client.path, serveStatic(PREVIEW_URL.client.local));
|
|
372
373
|
// add route for the sandbox html
|
|
373
374
|
this.router.get(this.flpConfig.path, async (req, res, next) => {
|
|
374
375
|
await this.flpGetHandler(req, res, next);
|
|
@@ -383,7 +384,7 @@ class FlpSandbox {
|
|
|
383
384
|
* @private
|
|
384
385
|
*/
|
|
385
386
|
async addCardGeneratorMiddlewareRoute() {
|
|
386
|
-
const previewGeneratorPath = this.cardGenerator?.path ??
|
|
387
|
+
const previewGeneratorPath = this.cardGenerator?.path ?? CARD_GENERATOR_DEFAULT.previewGeneratorSandbox;
|
|
387
388
|
this.logger.debug(`Add route for ${previewGeneratorPath}`);
|
|
388
389
|
this.router.get(previewGeneratorPath, async (req, res, next) => {
|
|
389
390
|
this.templateConfig.enableCardGenerator = !!this.cardGenerator?.path;
|
|
@@ -447,7 +448,7 @@ class FlpSandbox {
|
|
|
447
448
|
this.logger.info(`Using sandbox template for UI5 version: ${ui5Version.major}.${ui5Version.minor}.${ui5Version.patch}${ui5Version.label ? `-${ui5Version.label}` : ''}.`);
|
|
448
449
|
const filePrefix = ui5Version.major > 1 || ui5Version.label?.includes('legacy-free') ? '2' : '';
|
|
449
450
|
const template = this.flpConfig.enhancedHomePage ? 'cdm' : 'sandbox';
|
|
450
|
-
return
|
|
451
|
+
return readFileSync(join(__dirname, `../../templates/flp/${template}${filePrefix}.ejs`), 'utf-8');
|
|
451
452
|
}
|
|
452
453
|
/**
|
|
453
454
|
* For UI5 version 1.71 and below, the asyncHints.requests need to be removed from the template configuration
|
|
@@ -489,9 +490,9 @@ class FlpSandbox {
|
|
|
489
490
|
for (const app of this.flpConfig.apps) {
|
|
490
491
|
let manifest;
|
|
491
492
|
if (app.local) {
|
|
492
|
-
const webappPath = await
|
|
493
|
-
manifest = JSON.parse(
|
|
494
|
-
this.router.use(app.target, (
|
|
493
|
+
const webappPath = await getWebappPath(app.local, this.fs);
|
|
494
|
+
manifest = JSON.parse(readFileSync(join(webappPath, 'manifest.json'), 'utf-8'));
|
|
495
|
+
this.router.use(app.target, serveStatic(webappPath));
|
|
495
496
|
this.logger.info(`Serving additional application at ${app.target} from ${app.local}`);
|
|
496
497
|
}
|
|
497
498
|
else if (app.componentId) {
|
|
@@ -503,7 +504,7 @@ class FlpSandbox {
|
|
|
503
504
|
};
|
|
504
505
|
}
|
|
505
506
|
if (manifest) {
|
|
506
|
-
await
|
|
507
|
+
await addApp(this.templateConfig, manifest, app, this.logger);
|
|
507
508
|
this.logger.info(`Adding additional intent: ${app.intent?.object}-${app.intent?.action}`);
|
|
508
509
|
}
|
|
509
510
|
else {
|
|
@@ -517,7 +518,7 @@ class FlpSandbox {
|
|
|
517
518
|
*/
|
|
518
519
|
addCDMRoute() {
|
|
519
520
|
this.router.get('/cdm.json', async (_req, res) => {
|
|
520
|
-
const json =
|
|
521
|
+
const json = generateCdm(this.templateConfig.apps);
|
|
521
522
|
this.sendResponse(res, 'application/json', 200, JSON.stringify(json));
|
|
522
523
|
});
|
|
523
524
|
}
|
|
@@ -528,7 +529,7 @@ class FlpSandbox {
|
|
|
528
529
|
* @private
|
|
529
530
|
*/
|
|
530
531
|
async flexGetHandler(res) {
|
|
531
|
-
const changes = await
|
|
532
|
+
const changes = await readChanges(this.project, this.logger);
|
|
532
533
|
if (this.onChangeRequest) {
|
|
533
534
|
for (const change of Object.values(changes)) {
|
|
534
535
|
await this.onChangeRequest('read', change, this.fs, this.logger);
|
|
@@ -549,7 +550,7 @@ class FlpSandbox {
|
|
|
549
550
|
if (this.onChangeRequest) {
|
|
550
551
|
await this.onChangeRequest('write', body.change, this.fs, this.logger, body.additionalChangeInfo);
|
|
551
552
|
}
|
|
552
|
-
const { success, message } =
|
|
553
|
+
const { success, message } = writeChange(body.change, this.utils.getProject().getSourcePath(), this.fs, this.logger);
|
|
553
554
|
if (success) {
|
|
554
555
|
this.fs.commit(() => this.sendResponse(res, 'text/plain', 200, message ?? ''));
|
|
555
556
|
}
|
|
@@ -570,7 +571,7 @@ class FlpSandbox {
|
|
|
570
571
|
*/
|
|
571
572
|
async flexDeleteHandler(req, res) {
|
|
572
573
|
try {
|
|
573
|
-
const { success, message } =
|
|
574
|
+
const { success, message } = deleteChange(req.body, this.utils.getProject().getSourcePath(), this.logger);
|
|
574
575
|
if (success) {
|
|
575
576
|
this.sendResponse(res, 'text/plain', 200, message ?? '');
|
|
576
577
|
}
|
|
@@ -586,8 +587,8 @@ class FlpSandbox {
|
|
|
586
587
|
* Create required routes for flex.
|
|
587
588
|
*/
|
|
588
589
|
createFlexHandler() {
|
|
589
|
-
const api = `${
|
|
590
|
-
this.router.use(api,
|
|
590
|
+
const api = `${PREVIEW_URL.api}/changes`;
|
|
591
|
+
this.router.use(api, json());
|
|
591
592
|
this.router.get(api, async (_req, res) => {
|
|
592
593
|
await this.flexGetHandler(res);
|
|
593
594
|
});
|
|
@@ -612,7 +613,7 @@ class FlpSandbox {
|
|
|
612
613
|
basePath: this.templateConfig.basePath,
|
|
613
614
|
initPath: config.init
|
|
614
615
|
};
|
|
615
|
-
const html =
|
|
616
|
+
const html = render(testsuite, templateConfig);
|
|
616
617
|
this.sendResponse(res, 'text/html', 200, html);
|
|
617
618
|
}
|
|
618
619
|
/**
|
|
@@ -636,7 +637,7 @@ class FlpSandbox {
|
|
|
636
637
|
const templateConfig = {
|
|
637
638
|
testPaths: testPaths
|
|
638
639
|
};
|
|
639
|
-
const js =
|
|
640
|
+
const js = render(initTemplate, templateConfig);
|
|
640
641
|
this.sendResponse(res, 'application/javascript', 200, js);
|
|
641
642
|
}
|
|
642
643
|
}
|
|
@@ -656,8 +657,8 @@ class FlpSandbox {
|
|
|
656
657
|
this.logger.warn('Skip testsuite generation. No test frameworks configured.');
|
|
657
658
|
return;
|
|
658
659
|
}
|
|
659
|
-
const testsuite =
|
|
660
|
-
const config =
|
|
660
|
+
const testsuite = readFileSync(join(__dirname, '../../templates/test/testsuite.qunit.ejs'), 'utf-8');
|
|
661
|
+
const config = mergeTestConfigDefaults(testsuiteConfig);
|
|
661
662
|
this.logger.debug(`Add route for ${config.path}`);
|
|
662
663
|
this.router.get(config.path, async (_req, res) => {
|
|
663
664
|
await this.testSuiteHtmlGetHandler(res, testsuite, config);
|
|
@@ -671,10 +672,10 @@ class FlpSandbox {
|
|
|
671
672
|
if (testConfig.framework === 'Testsuite') {
|
|
672
673
|
continue;
|
|
673
674
|
}
|
|
674
|
-
const mergedConfig =
|
|
675
|
-
testPaths.push(
|
|
675
|
+
const mergedConfig = mergeTestConfigDefaults(testConfig);
|
|
676
|
+
testPaths.push(posix.relative(posix.dirname(config.path), mergedConfig.path));
|
|
676
677
|
}
|
|
677
|
-
const initTemplate =
|
|
678
|
+
const initTemplate = readFileSync(join(__dirname, '../../templates/test/testsuite.qunit.js'), 'utf-8');
|
|
678
679
|
this.logger.debug(`Add route for ${config.init}`);
|
|
679
680
|
this.router.get(config.init, async (_req, res, next) => {
|
|
680
681
|
await this.testSuiteJsGetHandler(res, next, config, initTemplate, testPaths);
|
|
@@ -715,8 +716,8 @@ class FlpSandbox {
|
|
|
715
716
|
next();
|
|
716
717
|
}
|
|
717
718
|
else {
|
|
718
|
-
const templateConfig =
|
|
719
|
-
const html =
|
|
719
|
+
const templateConfig = createTestTemplateConfig(config, id, this.templateConfig.ui5.theme);
|
|
720
|
+
const html = render(htmlTemplate, templateConfig);
|
|
720
721
|
this.sendResponse(res, 'text/html', 200, html);
|
|
721
722
|
}
|
|
722
723
|
}
|
|
@@ -739,8 +740,8 @@ class FlpSandbox {
|
|
|
739
740
|
}
|
|
740
741
|
else {
|
|
741
742
|
const testFiles = await this.project.byGlob(config.pattern);
|
|
742
|
-
const templateConfig = { tests:
|
|
743
|
-
const js =
|
|
743
|
+
const templateConfig = { tests: generateImportList(ns, testFiles) };
|
|
744
|
+
const js = render(initTemplate, templateConfig);
|
|
744
745
|
this.sendResponse(res, 'application/javascript', 200, js);
|
|
745
746
|
}
|
|
746
747
|
}
|
|
@@ -752,9 +753,9 @@ class FlpSandbox {
|
|
|
752
753
|
*/
|
|
753
754
|
addTestRoutes(configs, id) {
|
|
754
755
|
const ns = id.replace(/\./g, '/');
|
|
755
|
-
const htmlTemplate =
|
|
756
|
+
const htmlTemplate = readFileSync(join(__dirname, '../../templates/test/qunit.ejs'), 'utf-8');
|
|
756
757
|
for (const testConfig of configs) {
|
|
757
|
-
const config =
|
|
758
|
+
const config = mergeTestConfigDefaults(testConfig);
|
|
758
759
|
this.logger.debug(`Add route for ${config.path}`);
|
|
759
760
|
// add route for the *.qunit.html
|
|
760
761
|
this.router.get(config.path, async (_req, res, next) => {
|
|
@@ -765,7 +766,7 @@ class FlpSandbox {
|
|
|
765
766
|
continue;
|
|
766
767
|
}
|
|
767
768
|
// add route for the init file
|
|
768
|
-
const initTemplate =
|
|
769
|
+
const initTemplate = readFileSync(join(__dirname, '../../templates/test/qunit.js'), 'utf-8');
|
|
769
770
|
this.logger.debug(`Add route for ${config.init}`);
|
|
770
771
|
this.router.get(config.init, async (_req, res, next) => {
|
|
771
772
|
await this.testRunnerJsGetHandler(res, next, config, initTemplate, ns);
|
|
@@ -781,13 +782,13 @@ class FlpSandbox {
|
|
|
781
782
|
*/
|
|
782
783
|
async storeCardManifestHandler(req, res) {
|
|
783
784
|
try {
|
|
784
|
-
const { floorplan, localPath, fileName =
|
|
785
|
+
const { floorplan, localPath, fileName = FileName.Manifest, manifests } = req.body;
|
|
785
786
|
// getSourcePath() returns the webapp path directly for all project types
|
|
786
787
|
const webappPath = this.utils.getProject().getSourcePath();
|
|
787
|
-
const projectRoot =
|
|
788
|
-
const fullPath =
|
|
789
|
-
const filePath = fileName.endsWith('.json') ?
|
|
790
|
-
const integrationCard =
|
|
788
|
+
const projectRoot = dirname(webappPath);
|
|
789
|
+
const fullPath = join(webappPath, localPath);
|
|
790
|
+
const filePath = fileName.endsWith('.json') ? join(fullPath, fileName) : `${join(fullPath, fileName)}.json`;
|
|
791
|
+
const integrationCard = getIntegrationCard(manifests);
|
|
791
792
|
this.fs.write(filePath, JSON.stringify(integrationCard.manifest, null, 2));
|
|
792
793
|
const entitySet = integrationCard.entitySet;
|
|
793
794
|
const sapCardsAp = (this.manifest['sap.cards.ap'] ??= {});
|
|
@@ -802,7 +803,7 @@ class FlpSandbox {
|
|
|
802
803
|
]
|
|
803
804
|
}
|
|
804
805
|
};
|
|
805
|
-
const appAccess = await
|
|
806
|
+
const appAccess = await createApplicationAccess(projectRoot, this.fs);
|
|
806
807
|
await appAccess.updateManifestJSON(this.manifest, this.fs);
|
|
807
808
|
this.fs.commit(() => this.sendResponse(res, 'text/plain', 201, `Files were updated/created`));
|
|
808
809
|
}
|
|
@@ -818,9 +819,9 @@ class FlpSandbox {
|
|
|
818
819
|
* @returns {Promise<void>} A promise that resolves when the route is added.
|
|
819
820
|
*/
|
|
820
821
|
async addStoreCardManifestRoute() {
|
|
821
|
-
this.router.use(
|
|
822
|
-
this.logger.debug(`Add route for ${
|
|
823
|
-
this.router.post(
|
|
822
|
+
this.router.use(CARD_GENERATOR_DEFAULT.cardsStore, json());
|
|
823
|
+
this.logger.debug(`Add route for ${CARD_GENERATOR_DEFAULT.cardsStore}`);
|
|
824
|
+
this.router.post(CARD_GENERATOR_DEFAULT.cardsStore, async (req, res) => {
|
|
824
825
|
await this.storeCardManifestHandler(req, res);
|
|
825
826
|
});
|
|
826
827
|
}
|
|
@@ -843,7 +844,7 @@ class FlpSandbox {
|
|
|
843
844
|
this.sendResponse(res, 'text/plain', 400, `Locale "${requestedLocale}" is not supported. Supported: ${supportedLocales.join(', ')}`);
|
|
844
845
|
return;
|
|
845
846
|
}
|
|
846
|
-
const baseFilePath =
|
|
847
|
+
const baseFilePath = join(webappPath, i18nPath);
|
|
847
848
|
const filePath = requestedLocale
|
|
848
849
|
? baseFilePath.replace('.properties', `_${requestedLocale}.properties`)
|
|
849
850
|
: baseFilePath;
|
|
@@ -851,7 +852,7 @@ class FlpSandbox {
|
|
|
851
852
|
...entry,
|
|
852
853
|
annotation: entry.comment ?? entry.annotation
|
|
853
854
|
}));
|
|
854
|
-
await
|
|
855
|
+
await createPropertiesI18nEntries(filePath, entries);
|
|
855
856
|
this.fs.commit(() => this.sendResponse(res, 'text/plain', 201, `i18n file updated.`));
|
|
856
857
|
}
|
|
857
858
|
catch (error) {
|
|
@@ -908,9 +909,9 @@ class FlpSandbox {
|
|
|
908
909
|
* @returns {Promise<void>} A promise that resolves when the route is added.
|
|
909
910
|
*/
|
|
910
911
|
async addStoreI18nKeysRoute() {
|
|
911
|
-
this.router.use(
|
|
912
|
-
this.logger.debug(`Add route for ${
|
|
913
|
-
this.router.post(
|
|
912
|
+
this.router.use(CARD_GENERATOR_DEFAULT.i18nStore, json());
|
|
913
|
+
this.logger.debug(`Add route for ${CARD_GENERATOR_DEFAULT.i18nStore}`);
|
|
914
|
+
this.router.post(CARD_GENERATOR_DEFAULT.i18nStore, async (req, res) => {
|
|
914
915
|
await this.storeI18nKeysHandler(req, res);
|
|
915
916
|
});
|
|
916
917
|
}
|
|
@@ -921,8 +922,8 @@ class FlpSandbox {
|
|
|
921
922
|
* @throws Error in case no manifest.appdescr_variant found
|
|
922
923
|
*/
|
|
923
924
|
async initAdp(config) {
|
|
924
|
-
const variant = await
|
|
925
|
-
const adp = new
|
|
925
|
+
const variant = await loadAppVariant(this.project);
|
|
926
|
+
const adp = new AdpPreview(config, this.project, this.utils, this.logger);
|
|
926
927
|
const layer = await adp.init(variant);
|
|
927
928
|
// CF ADP build path mode: serve built resources directly from build output
|
|
928
929
|
if ('cfBuildPath' in config) {
|
|
@@ -932,11 +933,11 @@ class FlpSandbox {
|
|
|
932
933
|
await this.setupAdpCommonHandlers(adp);
|
|
933
934
|
return;
|
|
934
935
|
}
|
|
935
|
-
configureRta(this.rta, layer, variant.id, adp.projectType ===
|
|
936
|
+
configureRta(this.rta, layer, variant.id, adp.projectType === AdaptationProjectType.CLOUD_READY);
|
|
936
937
|
const descriptor = adp.descriptor;
|
|
937
938
|
const { name, manifest } = descriptor;
|
|
938
939
|
await this.init(manifest, name, adp.resources, adp);
|
|
939
|
-
const localModuleState = await
|
|
940
|
+
const localModuleState = await readLocalModulePaths(this.project, this.logger);
|
|
940
941
|
this.registerLrepFlexDataFilter(adp, localModuleState);
|
|
941
942
|
this.router.use(adp.descriptor.url, adp.proxy.bind(adp));
|
|
942
943
|
await this.setupAdpCommonHandlers(adp);
|
|
@@ -948,7 +949,7 @@ class FlpSandbox {
|
|
|
948
949
|
*/
|
|
949
950
|
async setupAdpCommonHandlers(adp) {
|
|
950
951
|
this.addOnChangeRequestHandler(adp.onChangeRequest.bind(adp));
|
|
951
|
-
this.router.use(
|
|
952
|
+
this.router.use(json());
|
|
952
953
|
adp.addApis(this.router);
|
|
953
954
|
// Register i18n store route for ADP projects (used by OVP bridge functions)
|
|
954
955
|
await this.addStoreI18nKeysRoute();
|
|
@@ -997,7 +998,7 @@ class FlpSandbox {
|
|
|
997
998
|
try {
|
|
998
999
|
const response = await provider.get(req.url);
|
|
999
1000
|
const responseData = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
|
|
1000
|
-
const filtered =
|
|
1001
|
+
const filtered = stripLocalModulesFromLrepResponse(responseData, localModuleState, this.logger);
|
|
1001
1002
|
res.status(200).json(filtered);
|
|
1002
1003
|
}
|
|
1003
1004
|
catch (error) {
|
|
@@ -1014,13 +1015,12 @@ class FlpSandbox {
|
|
|
1014
1015
|
* @returns the manifest
|
|
1015
1016
|
*/
|
|
1016
1017
|
setupCfBuildMode(cfBuildPath) {
|
|
1017
|
-
const manifest =
|
|
1018
|
-
this.router.use('/', (
|
|
1018
|
+
const manifest = readManifestFromBuildPath(cfBuildPath);
|
|
1019
|
+
this.router.use('/', serveStatic(cfBuildPath));
|
|
1019
1020
|
this.logger.info(`Initialized CF ADP with cfBuildPath, serving from ${cfBuildPath}`);
|
|
1020
1021
|
return manifest;
|
|
1021
1022
|
}
|
|
1022
1023
|
}
|
|
1023
|
-
exports.FlpSandbox = FlpSandbox;
|
|
1024
1024
|
/**
|
|
1025
1025
|
* Creates an attribute string that can be added to the UI5 bootstrap script of an HTML file.
|
|
1026
1026
|
*
|
package/dist/base/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { FlpSandbox } from './flp';
|
|
2
|
-
export { generatePreviewFiles, getPreviewPaths, sanitizeRtaConfig } from './config';
|
|
3
|
-
export { logRemoteUrl, isRemoteConnectionsEnabled } from './remote-url';
|
|
1
|
+
export { FlpSandbox } from './flp.js';
|
|
2
|
+
export { generatePreviewFiles, getPreviewPaths, sanitizeRtaConfig } from './config.js';
|
|
3
|
+
export { logRemoteUrl, isRemoteConnectionsEnabled } from './remote-url.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/base/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var flp_1 = require("./flp");
|
|
5
|
-
Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return flp_1.FlpSandbox; } });
|
|
6
|
-
var config_1 = require("./config");
|
|
7
|
-
Object.defineProperty(exports, "generatePreviewFiles", { enumerable: true, get: function () { return config_1.generatePreviewFiles; } });
|
|
8
|
-
Object.defineProperty(exports, "getPreviewPaths", { enumerable: true, get: function () { return config_1.getPreviewPaths; } });
|
|
9
|
-
Object.defineProperty(exports, "sanitizeRtaConfig", { enumerable: true, get: function () { return config_1.sanitizeRtaConfig; } });
|
|
10
|
-
var remote_url_1 = require("./remote-url");
|
|
11
|
-
Object.defineProperty(exports, "logRemoteUrl", { enumerable: true, get: function () { return remote_url_1.logRemoteUrl; } });
|
|
12
|
-
Object.defineProperty(exports, "isRemoteConnectionsEnabled", { enumerable: true, get: function () { return remote_url_1.isRemoteConnectionsEnabled; } });
|
|
1
|
+
export { FlpSandbox } from './flp.js';
|
|
2
|
+
export { generatePreviewFiles, getPreviewPaths, sanitizeRtaConfig } from './config.js';
|
|
3
|
+
export { logRemoteUrl, isRemoteConnectionsEnabled } from './remote-url.js';
|
|
13
4
|
//# sourceMappingURL=index.js.map
|
package/dist/base/remote-url.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logRemoteUrl = logRemoteUrl;
|
|
7
|
-
exports.getRemoteUrl = getRemoteUrl;
|
|
8
|
-
exports.isRemoteConnectionsEnabled = isRemoteConnectionsEnabled;
|
|
9
|
-
exports.getPortFromArgs = getPortFromArgs;
|
|
10
|
-
exports.getOpenPathFromArgs = getOpenPathFromArgs;
|
|
11
|
-
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
12
|
-
const node_os_1 = require("node:os");
|
|
13
|
-
const bas_sdk_1 = require("@sap/bas-sdk");
|
|
14
|
-
const qrcode_1 = __importDefault(require("qrcode"));
|
|
1
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
2
|
+
import { networkInterfaces } from 'node:os';
|
|
3
|
+
import { devspace } from '@sap/bas-sdk';
|
|
4
|
+
import QRCode from 'qrcode';
|
|
15
5
|
/**
|
|
16
6
|
* Log remote URL for mobile device access.
|
|
17
7
|
*
|
|
18
8
|
* @param logger ToolsLogger instance
|
|
19
9
|
*/
|
|
20
|
-
async function logRemoteUrl(logger) {
|
|
10
|
+
export async function logRemoteUrl(logger) {
|
|
21
11
|
try {
|
|
22
12
|
const remoteUrl = await getRemoteUrl(logger);
|
|
23
13
|
const generateQRCode = async (text) => {
|
|
24
14
|
try {
|
|
25
|
-
const qrString = await
|
|
15
|
+
const qrString = await QRCode.toString(text, { type: 'terminal', small: true });
|
|
26
16
|
logger.info(qrString);
|
|
27
17
|
}
|
|
28
18
|
catch (err) {
|
|
@@ -48,9 +38,9 @@ async function logRemoteUrl(logger) {
|
|
|
48
38
|
* @param logger ToolsLogger instance
|
|
49
39
|
* @returns The remote URL or undefined if not available
|
|
50
40
|
*/
|
|
51
|
-
async function getRemoteUrl(logger) {
|
|
41
|
+
export async function getRemoteUrl(logger) {
|
|
52
42
|
try {
|
|
53
|
-
if (
|
|
43
|
+
if (isAppStudio()) {
|
|
54
44
|
return await getBASRemoteUrl(logger);
|
|
55
45
|
}
|
|
56
46
|
else {
|
|
@@ -70,10 +60,10 @@ async function getRemoteUrl(logger) {
|
|
|
70
60
|
*/
|
|
71
61
|
async function getBASRemoteUrl(logger) {
|
|
72
62
|
try {
|
|
73
|
-
const devspaceInfo = await
|
|
63
|
+
const devspaceInfo = await devspace.getDevspaceInfo();
|
|
74
64
|
if (devspaceInfo?.url) {
|
|
75
65
|
const port = getPortFromArgs() ?? 8080;
|
|
76
|
-
const baseUrl =
|
|
66
|
+
const baseUrl = devspace.getAppExternalUri(`http://localhost:${port}`);
|
|
77
67
|
const devspaceUrl = baseUrl.replace(/(\/|%2F)$/, '');
|
|
78
68
|
const remoteUrl = appendOpenPath(devspaceUrl, getOpenPathFromArgs());
|
|
79
69
|
logger.debug(`BAS remote URL generated: ${remoteUrl}`);
|
|
@@ -119,7 +109,7 @@ function getIdeRemoteUrl(logger) {
|
|
|
119
109
|
* @returns The network IP address
|
|
120
110
|
*/
|
|
121
111
|
function getNetworkIP() {
|
|
122
|
-
const interfaces =
|
|
112
|
+
const interfaces = networkInterfaces();
|
|
123
113
|
// Priority order: prefer non-internal IPv4 addresses
|
|
124
114
|
for (const interfaceName of Object.keys(interfaces)) {
|
|
125
115
|
const networkInterface = interfaces[interfaceName];
|
|
@@ -155,7 +145,7 @@ function appendOpenPath(baseUrl, openPath) {
|
|
|
155
145
|
*
|
|
156
146
|
* @returns Whether --accept-remote-connections is present in process arguments
|
|
157
147
|
*/
|
|
158
|
-
function isRemoteConnectionsEnabled() {
|
|
148
|
+
export function isRemoteConnectionsEnabled() {
|
|
159
149
|
return process.argv.includes('--accept-remote-connections');
|
|
160
150
|
}
|
|
161
151
|
/**
|
|
@@ -163,7 +153,7 @@ function isRemoteConnectionsEnabled() {
|
|
|
163
153
|
*
|
|
164
154
|
* @returns The port number if found
|
|
165
155
|
*/
|
|
166
|
-
function getPortFromArgs() {
|
|
156
|
+
export function getPortFromArgs() {
|
|
167
157
|
// Check for --port argument
|
|
168
158
|
const portIndex = process.argv.findIndex((arg) => arg === '--port' || arg.startsWith('--port='));
|
|
169
159
|
if (portIndex !== -1) {
|
|
@@ -192,7 +182,7 @@ function getPortFromArgs() {
|
|
|
192
182
|
*
|
|
193
183
|
* @returns The path from --open or -o parameter if found
|
|
194
184
|
*/
|
|
195
|
-
function getOpenPathFromArgs() {
|
|
185
|
+
export function getOpenPathFromArgs() {
|
|
196
186
|
// Check for --open or -o argument
|
|
197
187
|
const openIndex = process.argv.findIndex((arg) => arg === '--open' || arg === '-o' || arg.startsWith('--open=') || arg.startsWith('--o='));
|
|
198
188
|
if (openIndex !== -1) {
|
package/dist/base/test.d.ts
CHANGED