@sap-ux/app-config-writer 0.7.6 → 1.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.
Files changed (46) hide show
  1. package/dist/cards-config/index.js +19 -22
  2. package/dist/common/package-json.js +19 -30
  3. package/dist/common/ui5-yaml.d.ts +2 -2
  4. package/dist/common/ui5-yaml.js +37 -48
  5. package/dist/common/utils.d.ts +1 -1
  6. package/dist/common/utils.js +13 -20
  7. package/dist/eslint-config/add.js +13 -16
  8. package/dist/eslint-config/convert.js +29 -35
  9. package/dist/eslint-config/index.d.ts +2 -2
  10. package/dist/eslint-config/index.js +2 -7
  11. package/dist/flp-embedded-config/index.js +11 -15
  12. package/dist/i18n.js +15 -25
  13. package/dist/index.d.ts +8 -8
  14. package/dist/index.js +8 -24
  15. package/dist/navigation-config/index.js +14 -18
  16. package/dist/preview-config/index.js +15 -18
  17. package/dist/preview-config/package-json.js +12 -16
  18. package/dist/preview-config/prerequisites.js +14 -17
  19. package/dist/preview-config/preview-files.js +28 -34
  20. package/dist/preview-config/ui5-yaml.d.ts +1 -1
  21. package/dist/preview-config/ui5-yaml.js +35 -40
  22. package/dist/prompt/index.d.ts +2 -2
  23. package/dist/prompt/index.js +2 -21
  24. package/dist/prompt/preview-config.js +6 -9
  25. package/dist/prompt/smartlinks-config.d.ts +1 -1
  26. package/dist/prompt/smartlinks-config.js +46 -49
  27. package/dist/smartlinks-config/generateSmartLinks.d.ts +1 -1
  28. package/dist/smartlinks-config/generateSmartLinks.js +6 -9
  29. package/dist/smartlinks-config/index.d.ts +2 -2
  30. package/dist/smartlinks-config/index.js +2 -21
  31. package/dist/smartlinks-config/ui5-yaml.d.ts +1 -1
  32. package/dist/smartlinks-config/ui5-yaml.js +14 -18
  33. package/dist/smartlinks-config/utils.d.ts +1 -1
  34. package/dist/smartlinks-config/utils.js +33 -40
  35. package/dist/templates.js +5 -6
  36. package/dist/types/index.d.ts +3 -3
  37. package/dist/types/index.js +3 -19
  38. package/dist/types/navigation.js +1 -2
  39. package/dist/types/smartLinks.js +4 -7
  40. package/dist/types/variantsConfig.js +2 -5
  41. package/dist/variants-config/generateVariantsConfig.js +8 -11
  42. package/dist/variants-config/index.d.ts +1 -1
  43. package/dist/variants-config/index.js +1 -17
  44. package/dist/variants-config/package-json.js +10 -13
  45. package/dist/variants-config/utils.js +13 -17
  46. package/package.json +13 -11
@@ -1,17 +1,11 @@
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.convertEslintConfig = convertEslintConfig;
7
- const mem_fs_editor_1 = require("mem-fs-editor");
8
- const mem_fs_1 = require("mem-fs");
9
- const node_path_1 = require("node:path");
10
- const project_access_1 = require("@sap-ux/project-access");
11
- const package_json_1 = require("../common/package-json");
12
- const cross_spawn_1 = __importDefault(require("cross-spawn"));
13
- const node_fs_1 = require("node:fs");
14
- const node_os_1 = require("node:os");
1
+ import { create } from 'mem-fs-editor';
2
+ import { create as createStorage } from 'mem-fs';
3
+ import { join } from 'node:path';
4
+ import { FileName, hasDependency } from '@sap-ux/project-access';
5
+ import { isLowerThanMinimalVersion } from '../common/package-json.js';
6
+ import crossSpawn from 'cross-spawn';
7
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
8
+ import { tmpdir } from 'node:os';
15
9
  const packageName = {
16
10
  ESLINT: 'eslint',
17
11
  ESLINT_MIGRATE_CONFIG: '@eslint/migrate-config',
@@ -47,8 +41,8 @@ const MIGRATION_ERROR_TEXT = `Migration to eslint version 9 failed. Check if the
47
41
  * @returns file system reference
48
42
  * @throws {Error} if the prerequisites are not met or if the conversion fails
49
43
  */
50
- async function convertEslintConfig(basePath, options) {
51
- const fs = options.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
44
+ export async function convertEslintConfig(basePath, options) {
45
+ const fs = options.fs ?? create(createStorage());
52
46
  const logger = options.logger;
53
47
  if (!(await checkPrerequisites(basePath, fs, logger))) {
54
48
  throw new Error('The prerequisites are not met. For more information, see the log messages above.');
@@ -68,25 +62,25 @@ async function convertEslintConfig(basePath, options) {
68
62
  * @returns true if the prerequisites are met, false otherwise
69
63
  */
70
64
  async function checkPrerequisites(basePath, fs, logger) {
71
- const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
65
+ const packageJsonPath = join(basePath, FileName.Package);
72
66
  const packageJson = fs.readJSON(packageJsonPath);
73
67
  if (!packageJson) {
74
68
  logger?.error(`No package.json found at path '${packageJsonPath}'`);
75
69
  return false;
76
70
  }
77
- if (!(0, project_access_1.hasDependency)(packageJson, packageName.ESLINT)) {
71
+ if (!hasDependency(packageJson, packageName.ESLINT)) {
78
72
  logger?.error(`Did not find ESLint dependency in package.json at path '${packageJsonPath}'. You might want to use the \`add eslint-config\` command instead.'`);
79
73
  return false;
80
74
  }
81
- if (!(0, package_json_1.isLowerThanMinimalVersion)(packageJson, packageName.ESLINT, '9.0.0')) {
75
+ if (!isLowerThanMinimalVersion(packageJson, packageName.ESLINT, '9.0.0')) {
82
76
  logger?.error(`ESLint version is already 9.0.0 or higher in this project. Found ESLint dependency with version '${packageJson.devDependencies?.eslint}' in package.json at path '${packageJsonPath}'`);
83
77
  return false;
84
78
  }
85
- if ((0, project_access_1.hasDependency)(packageJson, '@fxu/fincode')) {
79
+ if (hasDependency(packageJson, '@fxu/fincode')) {
86
80
  logger?.error(`Dependency to '@fxu/fincode' found at path '${basePath}'. Please remove the dependency and any usage of this package before running the conversion.`);
87
81
  return false;
88
82
  }
89
- if (!fs.exists((0, node_path_1.join)(basePath, '.eslintrc.json')) && !fs.exists((0, node_path_1.join)(basePath, '.eslintrc'))) {
83
+ if (!fs.exists(join(basePath, '.eslintrc.json')) && !fs.exists(join(basePath, '.eslintrc'))) {
90
84
  logger?.error(`No .eslintrc.json or .eslintrc found at path '${basePath}'`);
91
85
  return false;
92
86
  }
@@ -179,8 +173,8 @@ function warnIfFileScopeDropped(files, eslintRecommended, tsStripped, logger) {
179
173
  * @throws {Error} if the existing .eslintrc.json file is not a valid JSON object
180
174
  */
181
175
  async function removeFioriToolsFromExistingConfig(basePath, fs, logger) {
182
- const eslintrcJsonPath = (0, node_path_1.join)(basePath, '.eslintrc.json');
183
- const eslintrcPath = (0, node_path_1.join)(basePath, '.eslintrc');
176
+ const eslintrcJsonPath = join(basePath, '.eslintrc.json');
177
+ const eslintrcPath = join(basePath, '.eslintrc');
184
178
  const configPath = fs.exists(eslintrcJsonPath) ? eslintrcJsonPath : eslintrcPath;
185
179
  const eslintConfig = fs.readJSON(configPath);
186
180
  if (!eslintConfig || typeof eslintConfig !== 'object') {
@@ -212,7 +206,7 @@ async function removeFioriToolsFromExistingConfig(basePath, fs, logger) {
212
206
  * @param logger - logger to report info to the user
213
207
  */
214
208
  async function injectFioriToolsIntoMigratedConfig(basePath, fs, config = 'recommended', logger) {
215
- const migratedConfigPath = (0, node_path_1.join)(basePath, 'eslint.config.mjs');
209
+ const migratedConfigPath = join(basePath, 'eslint.config.mjs');
216
210
  let content = fs.read(migratedConfigPath);
217
211
  const importStatement = `import fioriTools from '${packageName.ESLINT_PLUGIN_FIORI_TOOLS}';\n`;
218
212
  if (!content.includes(importStatement)) {
@@ -239,26 +233,26 @@ async function injectFioriToolsIntoMigratedConfig(basePath, fs, config = 'recomm
239
233
  * @returns a promise that resolves when the migration command finishes successfully, or rejects if the command fails
240
234
  */
241
235
  async function runMigrationCommand(basePath, fs, strippedConfigContent) {
242
- const tempDir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'eslint-migration-'));
236
+ const tempDir = mkdtempSync(join(tmpdir(), 'eslint-migration-'));
243
237
  try {
244
238
  // 1. Copy necessary files to temp directory
245
- const eslintrcJsonPath = (0, node_path_1.join)(basePath, '.eslintrc.json');
239
+ const eslintrcJsonPath = join(basePath, '.eslintrc.json');
246
240
  const configFileName = fs.exists(eslintrcJsonPath) ? '.eslintrc.json' : '.eslintrc';
247
241
  // Write the already-stripped config content (never staged in mem-fs) to temp directory
248
- (0, node_fs_1.writeFileSync)((0, node_path_1.join)(tempDir, configFileName), strippedConfigContent, 'utf-8');
249
- const eslintignorePath = (0, node_path_1.join)(basePath, '.eslintignore');
250
- if ((0, node_fs_1.existsSync)(eslintignorePath)) {
251
- (0, node_fs_1.writeFileSync)((0, node_path_1.join)(tempDir, '.eslintignore'), (0, node_fs_1.readFileSync)(eslintignorePath, 'utf-8'), 'utf-8');
242
+ writeFileSync(join(tempDir, configFileName), strippedConfigContent, 'utf-8');
243
+ const eslintignorePath = join(basePath, '.eslintignore');
244
+ if (existsSync(eslintignorePath)) {
245
+ writeFileSync(join(tempDir, '.eslintignore'), readFileSync(eslintignorePath, 'utf-8'), 'utf-8');
252
246
  }
253
247
  // 2. Run migration in temp directory
254
248
  await spawnMigrationCommand(tempDir, configFileName);
255
249
  // 3. Write migrated config to mem-fs
256
- const migratedConfigPath = (0, node_path_1.join)(basePath, 'eslint.config.mjs');
257
- const migratedContent = (0, node_fs_1.readFileSync)((0, node_path_1.join)(tempDir, 'eslint.config.mjs'), 'utf-8');
250
+ const migratedConfigPath = join(basePath, 'eslint.config.mjs');
251
+ const migratedContent = readFileSync(join(tempDir, 'eslint.config.mjs'), 'utf-8');
258
252
  fs.write(migratedConfigPath, migratedContent);
259
253
  }
260
254
  finally {
261
- (0, node_fs_1.rmSync)(tempDir, { recursive: true, force: true });
255
+ rmSync(tempDir, { recursive: true, force: true });
262
256
  }
263
257
  }
264
258
  /**
@@ -270,7 +264,7 @@ async function runMigrationCommand(basePath, fs, strippedConfigContent) {
270
264
  */
271
265
  async function spawnMigrationCommand(basePath, configFileName) {
272
266
  return new Promise((resolve, reject) => {
273
- const child = (0, cross_spawn_1.default)('npx', ['--yes', packageName.ESLINT_MIGRATE_CONFIG, configFileName], {
267
+ const child = crossSpawn('npx', ['--yes', packageName.ESLINT_MIGRATE_CONFIG, configFileName], {
274
268
  cwd: basePath,
275
269
  shell: false,
276
270
  stdio: 'inherit'
@@ -296,7 +290,7 @@ async function spawnMigrationCommand(basePath, configFileName) {
296
290
  * @param logger - logger to report info to the user
297
291
  */
298
292
  async function updatePackageJson(basePath, fs, logger) {
299
- const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
293
+ const packageJsonPath = join(basePath, FileName.Package);
300
294
  const packageJson = fs.readJSON(packageJsonPath);
301
295
  packageJson.devDependencies ??= {};
302
296
  packageJson.devDependencies[packageName.ESLINT] = '^10.0.0';
@@ -1,3 +1,3 @@
1
- export { generateEslintConfig } from './add';
2
- export { convertEslintConfig } from './convert';
1
+ export { generateEslintConfig } from './add.js';
2
+ export { convertEslintConfig } from './convert.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertEslintConfig = exports.generateEslintConfig = void 0;
4
- var add_1 = require("./add");
5
- Object.defineProperty(exports, "generateEslintConfig", { enumerable: true, get: function () { return add_1.generateEslintConfig; } });
6
- var convert_1 = require("./convert");
7
- Object.defineProperty(exports, "convertEslintConfig", { enumerable: true, get: function () { return convert_1.convertEslintConfig; } });
1
+ export { generateEslintConfig } from './add.js';
2
+ export { convertEslintConfig } from './convert.js';
8
3
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_FLP_PATH = void 0;
4
- exports.generateFlpEmbeddedConfig = generateFlpEmbeddedConfig;
5
- const node_path_1 = require("node:path");
6
- const mem_fs_editor_1 = require("mem-fs-editor");
7
- const mem_fs_1 = require("mem-fs");
8
- const project_access_1 = require("@sap-ux/project-access");
9
- exports.DEFAULT_FLP_PATH = 'sap/bc/ui5_ui5/ui2/ushell/shells/abap/Fiorilaunchpad.html';
1
+ import { join } from 'node:path';
2
+ import { create } from 'mem-fs-editor';
3
+ import { create as createStorage } from 'mem-fs';
4
+ import { isCapProject, FileName, readUi5Yaml } from '@sap-ux/project-access';
5
+ export const DEFAULT_FLP_PATH = 'sap/bc/ui5_ui5/ui2/ushell/shells/abap/Fiorilaunchpad.html';
10
6
  /**
11
7
  * Generates the FLP Embedded Mode configuration for a Fiori app:
12
8
  * - adds the `start-embedded` npm script to package.json
@@ -20,15 +16,15 @@ exports.DEFAULT_FLP_PATH = 'sap/bc/ui5_ui5/ui2/ushell/shells/abap/Fiorilaunchpad
20
16
  * @param logger - optional logger
21
17
  * @returns mem-fs editor instance with modified/created files
22
18
  */
23
- async function generateFlpEmbeddedConfig(basePath, bspApplication, flpPath = exports.DEFAULT_FLP_PATH, yamlPath = project_access_1.FileName.Ui5Yaml, fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)()), logger) {
19
+ export async function generateFlpEmbeddedConfig(basePath, bspApplication, flpPath = DEFAULT_FLP_PATH, yamlPath = FileName.Ui5Yaml, fs = create(createStorage()), logger) {
24
20
  const bspApp = bspApplication.trim().toLowerCase();
25
21
  if (!bspApp) {
26
22
  throw new Error('Mandatory parameter bspApplication is missing.');
27
23
  }
28
- if (await (0, project_access_1.isCapProject)(basePath)) {
24
+ if (await isCapProject(basePath)) {
29
25
  throw new Error('CAP projects are not supported for FLP Embedded Mode configuration.');
30
26
  }
31
- const resolvedYamlPath = (0, node_path_1.join)(basePath, yamlPath);
27
+ const resolvedYamlPath = join(basePath, yamlPath);
32
28
  if (!fs.exists(resolvedYamlPath)) {
33
29
  throw new Error(`Configuration file ${resolvedYamlPath} not found. Please provide a valid path`);
34
30
  }
@@ -48,7 +44,7 @@ async function generateFlpEmbeddedConfig(basePath, bspApplication, flpPath = exp
48
44
  * @param logger - optional logger
49
45
  */
50
46
  function addStartEmbeddedScript(fs, basePath, flpPath, logger) {
51
- const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
47
+ const packageJsonPath = join(basePath, FileName.Package);
52
48
  const packageJson = fs.readJSON(packageJsonPath);
53
49
  if (!packageJson) {
54
50
  throw new Error(`File 'package.json' not found at ${basePath}`);
@@ -70,8 +66,8 @@ function addStartEmbeddedScript(fs, basePath, flpPath, logger) {
70
66
  * @param logger - optional logger
71
67
  */
72
68
  async function addFlpYaml(fs, basePath, yamlFileName, bspApplication, logger) {
73
- const flpYamlPath = (0, node_path_1.join)(basePath, 'flp.yaml');
74
- const ui5Config = await (0, project_access_1.readUi5Yaml)(basePath, yamlFileName, fs);
69
+ const flpYamlPath = join(basePath, 'flp.yaml');
70
+ const ui5Config = await readUi5Yaml(basePath, yamlFileName, fs);
75
71
  const metadata = ui5Config.getMetadata();
76
72
  if (!metadata?.name) {
77
73
  throw new Error(`The configuration file '${yamlFileName}' is missing a 'metadata.name' field.`);
package/dist/i18n.js CHANGED
@@ -1,32 +1,24 @@
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.i18n = exports.NAV_CONFIG_NS = exports.SMART_LINKS_NS = void 0;
7
- exports.initI18n = initI18n;
8
- exports.t = t;
9
- const i18next_1 = __importDefault(require("i18next"));
10
- const smartlinks_config_json_1 = __importDefault(require("./translations/smartlinks-config.json"));
11
- const navigation_config_json_1 = __importDefault(require("./translations/navigation-config.json"));
12
- exports.SMART_LINKS_NS = 'app-config-writer:smartLinksConfig';
13
- exports.NAV_CONFIG_NS = 'app-config-writer:navConfig';
14
- exports.i18n = i18next_1.default.createInstance();
1
+ import i18next from 'i18next';
2
+ import smartLinksRes from './translations/smartlinks-config.json' with { type: 'json' };
3
+ import navConfigRes from './translations/navigation-config.json' with { type: 'json' };
4
+ export const SMART_LINKS_NS = 'app-config-writer:smartLinksConfig';
5
+ export const NAV_CONFIG_NS = 'app-config-writer:navConfig';
6
+ export const i18n = i18next.createInstance();
15
7
  /**
16
8
  * Initialize i18next with the translations for this module.
17
9
  */
18
- async function initI18n() {
19
- await exports.i18n.init({
10
+ export async function initI18n() {
11
+ await i18n.init({
20
12
  resources: {
21
13
  en: {
22
- [exports.SMART_LINKS_NS]: smartlinks_config_json_1.default,
23
- [exports.NAV_CONFIG_NS]: navigation_config_json_1.default
14
+ [SMART_LINKS_NS]: smartLinksRes,
15
+ [NAV_CONFIG_NS]: navConfigRes
24
16
  }
25
17
  },
26
18
  lng: 'en',
27
19
  fallbackLng: 'en',
28
- defaultNS: exports.SMART_LINKS_NS, // Default since first to add translations
29
- ns: [exports.SMART_LINKS_NS, exports.NAV_CONFIG_NS],
20
+ defaultNS: SMART_LINKS_NS, // Default since first to add translations
21
+ ns: [SMART_LINKS_NS, NAV_CONFIG_NS],
30
22
  showSupportNotice: false
31
23
  });
32
24
  }
@@ -37,10 +29,8 @@ async function initI18n() {
37
29
  * @param options additional options
38
30
  * @returns {string} localized string stored for the given key
39
31
  */
40
- function t(key, options) {
41
- return exports.i18n.t(key, options);
32
+ export function t(key, options) {
33
+ return i18n.t(key, options);
42
34
  }
43
- initI18n().catch(() => {
44
- // Ignore any errors since the write will still work
45
- });
35
+ void initI18n().catch(() => undefined);
46
36
  //# sourceMappingURL=i18n.js.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export { getSmartLinksTargetFromPrompt, simulatePrompt, includeTestRunnersPrompt } from './prompt';
2
- export { generateSmartLinksConfig } from './smartlinks-config';
3
- export { generateEslintConfig, convertEslintConfig } from './eslint-config';
4
- export { generateInboundNavigationConfig, readManifest } from './navigation-config';
5
- export { generateVariantsConfig } from './variants-config';
6
- export { convertToVirtualPreview } from './preview-config';
7
- export { enableCardGeneratorConfig } from './cards-config';
8
- export { generateFlpEmbeddedConfig, DEFAULT_FLP_PATH } from './flp-embedded-config';
1
+ export { getSmartLinksTargetFromPrompt, simulatePrompt, includeTestRunnersPrompt } from './prompt/index.js';
2
+ export { generateSmartLinksConfig } from './smartlinks-config/index.js';
3
+ export { generateEslintConfig, convertEslintConfig } from './eslint-config/index.js';
4
+ export { generateInboundNavigationConfig, readManifest } from './navigation-config/index.js';
5
+ export { generateVariantsConfig } from './variants-config/index.js';
6
+ export { convertToVirtualPreview } from './preview-config/index.js';
7
+ export { enableCardGeneratorConfig } from './cards-config/index.js';
8
+ export { generateFlpEmbeddedConfig, DEFAULT_FLP_PATH } from './flp-embedded-config/index.js';
9
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,25 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_FLP_PATH = exports.generateFlpEmbeddedConfig = exports.enableCardGeneratorConfig = exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.convertEslintConfig = exports.generateEslintConfig = exports.generateSmartLinksConfig = exports.includeTestRunnersPrompt = exports.simulatePrompt = exports.getSmartLinksTargetFromPrompt = void 0;
4
- var prompt_1 = require("./prompt");
5
- Object.defineProperty(exports, "getSmartLinksTargetFromPrompt", { enumerable: true, get: function () { return prompt_1.getSmartLinksTargetFromPrompt; } });
6
- Object.defineProperty(exports, "simulatePrompt", { enumerable: true, get: function () { return prompt_1.simulatePrompt; } });
7
- Object.defineProperty(exports, "includeTestRunnersPrompt", { enumerable: true, get: function () { return prompt_1.includeTestRunnersPrompt; } });
8
- var smartlinks_config_1 = require("./smartlinks-config");
9
- Object.defineProperty(exports, "generateSmartLinksConfig", { enumerable: true, get: function () { return smartlinks_config_1.generateSmartLinksConfig; } });
10
- var eslint_config_1 = require("./eslint-config");
11
- Object.defineProperty(exports, "generateEslintConfig", { enumerable: true, get: function () { return eslint_config_1.generateEslintConfig; } });
12
- Object.defineProperty(exports, "convertEslintConfig", { enumerable: true, get: function () { return eslint_config_1.convertEslintConfig; } });
13
- var navigation_config_1 = require("./navigation-config");
14
- Object.defineProperty(exports, "generateInboundNavigationConfig", { enumerable: true, get: function () { return navigation_config_1.generateInboundNavigationConfig; } });
15
- Object.defineProperty(exports, "readManifest", { enumerable: true, get: function () { return navigation_config_1.readManifest; } });
16
- var variants_config_1 = require("./variants-config");
17
- Object.defineProperty(exports, "generateVariantsConfig", { enumerable: true, get: function () { return variants_config_1.generateVariantsConfig; } });
18
- var preview_config_1 = require("./preview-config");
19
- Object.defineProperty(exports, "convertToVirtualPreview", { enumerable: true, get: function () { return preview_config_1.convertToVirtualPreview; } });
20
- var cards_config_1 = require("./cards-config");
21
- Object.defineProperty(exports, "enableCardGeneratorConfig", { enumerable: true, get: function () { return cards_config_1.enableCardGeneratorConfig; } });
22
- var flp_embedded_config_1 = require("./flp-embedded-config");
23
- Object.defineProperty(exports, "generateFlpEmbeddedConfig", { enumerable: true, get: function () { return flp_embedded_config_1.generateFlpEmbeddedConfig; } });
24
- Object.defineProperty(exports, "DEFAULT_FLP_PATH", { enumerable: true, get: function () { return flp_embedded_config_1.DEFAULT_FLP_PATH; } });
1
+ export { getSmartLinksTargetFromPrompt, simulatePrompt, includeTestRunnersPrompt } from './prompt/index.js';
2
+ export { generateSmartLinksConfig } from './smartlinks-config/index.js';
3
+ export { generateEslintConfig, convertEslintConfig } from './eslint-config/index.js';
4
+ export { generateInboundNavigationConfig, readManifest } from './navigation-config/index.js';
5
+ export { generateVariantsConfig } from './variants-config/index.js';
6
+ export { convertToVirtualPreview } from './preview-config/index.js';
7
+ export { enableCardGeneratorConfig } from './cards-config/index.js';
8
+ export { generateFlpEmbeddedConfig, DEFAULT_FLP_PATH } from './flp-embedded-config/index.js';
25
9
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateInboundNavigationConfig = generateInboundNavigationConfig;
4
- exports.readManifest = readManifest;
5
- const project_access_1 = require("@sap-ux/project-access");
6
- const mem_fs_1 = require("mem-fs");
7
- const mem_fs_editor_1 = require("mem-fs-editor");
8
- const ui5_config_1 = require("@sap-ux/ui5-config");
9
- const node_path_1 = require("node:path");
10
- const i18n_1 = require("../i18n");
1
+ import { FileName, getWebappPath } from '@sap-ux/project-access';
2
+ import { create as createStorage } from 'mem-fs';
3
+ import { create } from 'mem-fs-editor';
4
+ import { mergeObjects } from '@sap-ux/ui5-config';
5
+ import { join } from 'node:path';
6
+ import { NAV_CONFIG_NS, t } from '../i18n.js';
11
7
  /**
12
8
  * Adds a basic inbound navigation configuration to the application manifest.
13
9
  *
@@ -21,14 +17,14 @@ const i18n_1 = require("../i18n");
21
17
  * @param fs file system reference
22
18
  * @returns file system reference
23
19
  */
24
- async function generateInboundNavigationConfig(appRootPath, { semanticObject, action, title, subTitle }, overwrite = false, fs) {
20
+ export async function generateInboundNavigationConfig(appRootPath, { semanticObject, action, title, subTitle }, overwrite = false, fs) {
25
21
  if (!fs) {
26
- fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
22
+ fs = create(createStorage());
27
23
  }
28
24
  const { manifest, manifestPath } = await readManifest(appRootPath, fs);
29
25
  const inboundKey = `${semanticObject}-${action}`;
30
26
  if (!overwrite && manifest['sap.app'].crossNavigation?.inbounds[inboundKey]) {
31
- throw Error((0, i18n_1.t)('error.inboundExists', { inboundKey, ns: i18n_1.NAV_CONFIG_NS }));
27
+ throw Error(t('error.inboundExists', { inboundKey, ns: NAV_CONFIG_NS }));
32
28
  }
33
29
  const inbound = {
34
30
  [inboundKey]: {
@@ -43,7 +39,7 @@ async function generateInboundNavigationConfig(appRootPath, { semanticObject, ac
43
39
  }
44
40
  };
45
41
  const crossNavigation = Object.assign(manifest['sap.app'].crossNavigation ?? {}, {
46
- inbounds: (0, ui5_config_1.mergeObjects)(manifest['sap.app'].crossNavigation?.inbounds, inbound)
42
+ inbounds: mergeObjects(manifest['sap.app'].crossNavigation?.inbounds, inbound)
47
43
  });
48
44
  fs.extendJSON(manifestPath, { 'sap.app': Object.assign(manifest['sap.app'], { crossNavigation }) });
49
45
  return fs;
@@ -56,14 +52,14 @@ async function generateInboundNavigationConfig(appRootPath, { semanticObject, ac
56
52
  * @throws an error specifiying the validation failure
57
53
  * @returns the manifest object and manifest path
58
54
  */
59
- async function readManifest(appPath, fs) {
60
- const manifestPath = (0, node_path_1.join)(await (0, project_access_1.getWebappPath)(appPath, fs), project_access_1.FileName.Manifest);
55
+ export async function readManifest(appPath, fs) {
56
+ const manifestPath = join(await getWebappPath(appPath, fs), FileName.Manifest);
61
57
  const manifest = fs.readJSON(manifestPath);
62
58
  if (!manifest) {
63
- throw Error((0, i18n_1.t)('error.manifestNotFound', { path: manifestPath, ns: i18n_1.NAV_CONFIG_NS }));
59
+ throw Error(t('error.manifestNotFound', { path: manifestPath, ns: NAV_CONFIG_NS }));
64
60
  }
65
61
  if (!manifest['sap.app']) {
66
- throw Error((0, i18n_1.t)('error.sapAppNotDefined', { ns: i18n_1.NAV_CONFIG_NS }));
62
+ throw Error(t('error.sapAppNotDefined', { ns: NAV_CONFIG_NS }));
67
63
  }
68
64
  return {
69
65
  manifest,
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToVirtualPreview = convertToVirtualPreview;
4
- const prerequisites_1 = require("./prerequisites");
5
- const mem_fs_1 = require("mem-fs");
6
- const mem_fs_editor_1 = require("mem-fs-editor");
7
- const preview_files_1 = require("./preview-files");
8
- const ui5_yaml_1 = require("./ui5-yaml");
9
- const package_json_1 = require("./package-json");
1
+ import { checkPrerequisites } from './prerequisites.js';
2
+ import { create as createStorage } from 'mem-fs';
3
+ import { create } from 'mem-fs-editor';
4
+ import { deleteNoLongerUsedFiles, renameDefaultSandboxes, renameDefaultTestFiles } from './preview-files.js';
5
+ import { updatePreviewMiddlewareConfigs, updateDefaultTestConfig } from './ui5-yaml.js';
6
+ import { updateVariantsCreationScript } from './package-json.js';
10
7
  /**
11
8
  * Converts the local preview files of a project to virtual files.
12
9
  *
@@ -21,21 +18,21 @@ const package_json_1 = require("./package-json");
21
18
  * @param options.fs - file system reference
22
19
  * @returns file system reference
23
20
  */
24
- async function convertToVirtualPreview(basePath, options) {
25
- const fs = options.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
21
+ export async function convertToVirtualPreview(basePath, options) {
22
+ const fs = options.fs ?? create(createStorage());
26
23
  const logger = options.logger;
27
24
  const convertTests = options.convertTests ?? false;
28
- if (!(await (0, prerequisites_1.checkPrerequisites)(basePath, fs, convertTests, logger))) {
25
+ if (!(await checkPrerequisites(basePath, fs, convertTests, logger))) {
29
26
  throw new Error('The prerequisites are not met. For more information, see the log messages above.');
30
27
  }
31
- await (0, ui5_yaml_1.updatePreviewMiddlewareConfigs)(fs, basePath, convertTests, logger);
32
- await (0, preview_files_1.renameDefaultSandboxes)(fs, basePath, logger);
28
+ await updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger);
29
+ await renameDefaultSandboxes(fs, basePath, logger);
33
30
  if (convertTests) {
34
- await (0, preview_files_1.renameDefaultTestFiles)(fs, basePath, logger);
35
- await (0, ui5_yaml_1.updateDefaultTestConfig)(fs, basePath, logger);
31
+ await renameDefaultTestFiles(fs, basePath, logger);
32
+ await updateDefaultTestConfig(fs, basePath, logger);
36
33
  }
37
- await (0, preview_files_1.deleteNoLongerUsedFiles)(fs, basePath, convertTests, logger);
38
- await (0, package_json_1.updateVariantsCreationScript)(fs, basePath, logger);
34
+ await deleteNoLongerUsedFiles(fs, basePath, convertTests, logger);
35
+ await updateVariantsCreationScript(fs, basePath, logger);
39
36
  return fs;
40
37
  }
41
38
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensurePreviewMiddlewareDependency = ensurePreviewMiddlewareDependency;
4
- exports.updateVariantsCreationScript = updateVariantsCreationScript;
5
- const node_path_1 = require("node:path");
6
- const package_json_1 = require("../common/package-json");
7
- const variants_config_1 = require("../variants-config");
8
- const project_access_1 = require("@sap-ux/project-access");
1
+ import { basename, join } from 'node:path';
2
+ import { extractYamlConfigFileName } from '../common/package-json.js';
3
+ import { generateVariantsConfig } from '../variants-config/index.js';
4
+ import { hasDependency } from '@sap-ux/project-access';
9
5
  /**
10
6
  * Ensures that the @sap/ux-ui5-tooling or @sap-ux/preview-middleware dependency exists in the package.json.
11
7
  *
@@ -14,14 +10,14 @@ const project_access_1 = require("@sap-ux/project-access");
14
10
  * @param fs - file system reference
15
11
  * @param basePath - base path to be used for the conversion
16
12
  */
17
- function ensurePreviewMiddlewareDependency(fs, basePath) {
18
- const packageJsonPath = (0, node_path_1.join)(basePath, 'package.json');
13
+ export function ensurePreviewMiddlewareDependency(fs, basePath) {
14
+ const packageJsonPath = join(basePath, 'package.json');
19
15
  const packageJson = fs.readJSON(packageJsonPath);
20
16
  if (!packageJson) {
21
17
  return;
22
18
  }
23
19
  const dependencies = ['@sap-ux/preview-middleware', '@sap/ux-ui5-tooling'];
24
- if (dependencies.some((dependency) => (0, project_access_1.hasDependency)(packageJson, dependency))) {
20
+ if (dependencies.some((dependency) => hasDependency(packageJson, dependency))) {
25
21
  return;
26
22
  }
27
23
  packageJson.devDependencies = { ...packageJson.devDependencies, '@sap-ux/preview-middleware': 'latest' };
@@ -36,13 +32,13 @@ function ensurePreviewMiddlewareDependency(fs, basePath) {
36
32
  * @param basePath - base path to be used for the conversion
37
33
  * @param logger logger to report info to the user
38
34
  */
39
- async function updateVariantsCreationScript(fs, basePath, logger) {
40
- const packageJsonPath = (0, node_path_1.join)(basePath, 'package.json');
35
+ export async function updateVariantsCreationScript(fs, basePath, logger) {
36
+ const packageJsonPath = join(basePath, 'package.json');
41
37
  const packageJson = fs.readJSON(packageJsonPath);
42
38
  if (packageJson?.scripts?.['start-variants-management']) {
43
- const ui5Yaml = (0, node_path_1.basename)((0, package_json_1.extractYamlConfigFileName)(packageJson?.scripts?.['start-variants-management']));
44
- const yamlPath = (0, node_path_1.join)(basePath, ui5Yaml);
45
- await (0, variants_config_1.generateVariantsConfig)(basePath, yamlPath, logger, fs);
39
+ const ui5Yaml = basename(extractYamlConfigFileName(packageJson?.scripts?.['start-variants-management']));
40
+ const yamlPath = join(basePath, ui5Yaml);
41
+ await generateVariantsConfig(basePath, yamlPath, logger, fs);
46
42
  }
47
43
  }
48
44
  //# sourceMappingURL=package-json.js.map
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkPrerequisites = checkPrerequisites;
4
- const node_path_1 = require("node:path");
5
- const project_access_1 = require("@sap-ux/project-access");
6
- const package_json_1 = require("../common/package-json");
1
+ import { join } from 'node:path';
2
+ import { findCapProjectRoot, FileName, checkCdsUi5PluginEnabled, hasDependency } from '@sap-ux/project-access';
3
+ import { isLowerThanMinimalVersion } from '../common/package-json.js';
7
4
  const packageName = {
8
5
  WDIO_QUNIT_SERVICE: 'wdio-qunit-service',
9
6
  KARMA_UI5: 'karma-ui5',
@@ -20,11 +17,11 @@ const packageName = {
20
17
  * @returns indicator if the project is a CAP project that uses 'cds-plugin-ui5'
21
18
  */
22
19
  async function isUsingCdsPluginUi5(basePath, fs) {
23
- const capProjectRootPath = await (0, project_access_1.findCapProjectRoot)(basePath, false, fs);
20
+ const capProjectRootPath = await findCapProjectRoot(basePath, false, fs);
24
21
  if (!capProjectRootPath) {
25
22
  return false;
26
23
  }
27
- return await (0, project_access_1.checkCdsUi5PluginEnabled)(capProjectRootPath, fs);
24
+ return await checkCdsUi5PluginEnabled(capProjectRootPath, fs);
28
25
  }
29
26
  /**
30
27
  * Check if the prerequisites for the conversion are met.
@@ -38,34 +35,34 @@ async function isUsingCdsPluginUi5(basePath, fs) {
38
35
  * @param logger logger to report info to the user
39
36
  * @returns indicator if the prerequisites are met
40
37
  */
41
- async function checkPrerequisites(basePath, fs, convertTests = false, logger) {
42
- const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
38
+ export async function checkPrerequisites(basePath, fs, convertTests = false, logger) {
39
+ const packageJsonPath = join(basePath, FileName.Package);
43
40
  const packageJson = fs.readJSON(packageJsonPath);
44
41
  let prerequisitesMet = true;
45
42
  if (!packageJson) {
46
- throw Error(`File '${project_access_1.FileName.Package}' not found at '${basePath}'`);
43
+ throw Error(`File '${FileName.Package}' not found at '${basePath}'`);
47
44
  }
48
- if ((0, project_access_1.hasDependency)(packageJson, packageName.SAP_GRUNT_SAPUI5_BESTPRACTICE_BUILD)) {
45
+ if (hasDependency(packageJson, packageName.SAP_GRUNT_SAPUI5_BESTPRACTICE_BUILD)) {
49
46
  logger?.error(`Conversion from '${packageName.SAP_GRUNT_SAPUI5_BESTPRACTICE_BUILD}' is not supported. You must migrate to UI5 CLI version 3.0.0 or higher. For more information, see https://sap.github.io/ui5-tooling/v3/updates/migrate-v3.`);
50
47
  prerequisitesMet = false;
51
48
  }
52
- if ((0, package_json_1.isLowerThanMinimalVersion)(packageJson, packageName.UI5_CLI, '3.0.0')) {
49
+ if (isLowerThanMinimalVersion(packageJson, packageName.UI5_CLI, '3.0.0')) {
53
50
  logger?.error('UI5 CLI version 3.0.0 or higher is required to convert the preview to virtual files. For more information, see https://sap.github.io/ui5-tooling/v3/updates/migrate-v3.');
54
51
  prerequisitesMet = false;
55
52
  }
56
- if ((0, package_json_1.isLowerThanMinimalVersion)(packageJson, packageName.SAP_UX_UI5_TOOLING, '1.15.4', false)) {
53
+ if (isLowerThanMinimalVersion(packageJson, packageName.SAP_UX_UI5_TOOLING, '1.15.4', false)) {
57
54
  logger?.error('UX UI5 Tooling version 1.15.4 or higher is required to convert the preview to virtual files. For more information, see https://www.npmjs.com/package/@sap/ux-ui5-tooling.');
58
55
  prerequisitesMet = false;
59
56
  }
60
- if (!(0, project_access_1.hasDependency)(packageJson, packageName.SAP_UX_UI5_MIDDLEWARE_FE_MOCKSERVER) &&
57
+ if (!hasDependency(packageJson, packageName.SAP_UX_UI5_MIDDLEWARE_FE_MOCKSERVER) &&
61
58
  !(await isUsingCdsPluginUi5(basePath, fs))) {
62
59
  logger?.error(`Conversion from 'sap/ui/core/util/MockServer' or '@sap/ux-ui5-fe-mockserver-middleware' is not supported. You must migrate to '${packageName.SAP_UX_UI5_MIDDLEWARE_FE_MOCKSERVER}' first. For more information, see https://www.npmjs.com/package/@sap-ux/ui5-middleware-fe-mockserver.`);
63
60
  prerequisitesMet = false;
64
61
  }
65
- if (convertTests && (0, project_access_1.hasDependency)(packageJson, packageName.KARMA_UI5)) {
62
+ if (convertTests && hasDependency(packageJson, packageName.KARMA_UI5)) {
66
63
  logger?.warn("This app seems to use Karma as a test runner. Please note that the converter does not convert any Karma configuration files. Please update your karma configuration ('ui5.configPath' and 'ui5.testpage') according to the new virtual endpoints after the conversion.");
67
64
  }
68
- if (convertTests && (0, project_access_1.hasDependency)(packageJson, packageName.WDIO_QUNIT_SERVICE)) {
65
+ if (convertTests && hasDependency(packageJson, packageName.WDIO_QUNIT_SERVICE)) {
69
66
  logger?.warn('This app seems to use the WebdriverIO QUnit Service as a test runner. Please note that the converter does not convert any WebdriverIO configuration files. Please update your WebdriverIO QUnit Service test paths according to the new virtual endpoints after the conversion.');
70
67
  }
71
68
  return prerequisitesMet;