@sap-ux/create 0.17.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/cli/add/adp-cf-config.js +14 -17
  2. package/dist/cli/add/annotations-to-odata.js +20 -23
  3. package/dist/cli/add/cards-generator.js +11 -14
  4. package/dist/cli/add/cds-plugin-ui.js +11 -14
  5. package/dist/cli/add/component-usages.js +13 -17
  6. package/dist/cli/add/deploy-config.js +23 -25
  7. package/dist/cli/add/eslint-config.js +13 -16
  8. package/dist/cli/add/flp-embedded-config.js +8 -11
  9. package/dist/cli/add/html.js +18 -21
  10. package/dist/cli/add/index.js +33 -36
  11. package/dist/cli/add/mockserver-config.js +19 -21
  12. package/dist/cli/add/navigation-config.js +38 -41
  13. package/dist/cli/add/new-model.js +11 -14
  14. package/dist/cli/add/smartlinks-config.js +10 -13
  15. package/dist/cli/add/system.js +22 -25
  16. package/dist/cli/add/variants-config.js +13 -16
  17. package/dist/cli/change/change-data-source.js +18 -21
  18. package/dist/cli/change/change-inbound.js +13 -16
  19. package/dist/cli/change/index.js +9 -12
  20. package/dist/cli/change/system.js +12 -15
  21. package/dist/cli/convert/eslint-config.js +15 -18
  22. package/dist/cli/convert/index.js +7 -10
  23. package/dist/cli/convert/preview.js +10 -13
  24. package/dist/cli/generate/adaptation-project.js +14 -20
  25. package/dist/cli/generate/index.js +5 -8
  26. package/dist/cli/get/index.js +5 -8
  27. package/dist/cli/get/system.js +10 -13
  28. package/dist/cli/index.js +27 -29
  29. package/dist/cli/list/index.js +5 -8
  30. package/dist/cli/list/system.js +9 -12
  31. package/dist/cli/remove/index.js +7 -10
  32. package/dist/cli/remove/mockserver-config.js +12 -18
  33. package/dist/cli/remove/system.js +8 -11
  34. package/dist/common/index.d.ts +1 -1
  35. package/dist/common/index.js +4 -9
  36. package/dist/common/prompts.js +7 -15
  37. package/dist/index.js +2 -4
  38. package/dist/tracing/compare.js +12 -16
  39. package/dist/tracing/index.d.ts +2 -2
  40. package/dist/tracing/index.js +2 -8
  41. package/dist/tracing/logger.js +9 -15
  42. package/dist/tracing/trace.js +11 -14
  43. package/dist/validation/index.d.ts +1 -1
  44. package/dist/validation/index.js +1 -8
  45. package/dist/validation/validation.js +15 -21
  46. package/package.json +24 -22
package/dist/cli/index.js CHANGED
@@ -1,18 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleCreateFioriCommand = handleCreateFioriCommand;
4
- exports.generateJsonSpec = generateJsonSpec;
5
- const node_fs_1 = require("node:fs");
6
- const node_path_1 = require("node:path");
7
- const commander_1 = require("commander");
8
- const tracing_1 = require("../tracing");
9
- const add_1 = require("./add");
10
- const remove_1 = require("./remove");
11
- const generate_1 = require("./generate");
12
- const change_1 = require("./change");
13
- const convert_1 = require("./convert");
14
- const list_1 = require("./list");
15
- const get_1 = require("./get");
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { Command } from 'commander';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ import { getLogger } from '../tracing/index.js';
7
+ import { getAddCommands } from './add/index.js';
8
+ import { getRemoveCommands } from './remove/index.js';
9
+ import { getGenerateCommands } from './generate/index.js';
10
+ import { getChangeCommands } from './change/index.js';
11
+ import { getConvertCommands } from './convert/index.js';
12
+ import { getListCommands } from './list/index.js';
13
+ import { getGetCommands } from './get/index.js';
16
14
  /*
17
15
  * We've chosen 'commander' over 'minimist' and 'yargs' for this CLI implementation. Reasons:
18
16
  * (if it still up: https://npmtrends.com/commander-vs-minimist-vs-yargs)
@@ -25,8 +23,8 @@ const get_1 = require("./get");
25
23
  *
26
24
  * @param argv - arguments, typically 'process.argv'
27
25
  */
28
- function handleCreateFioriCommand(argv) {
29
- const logger = (0, tracing_1.getLogger)();
26
+ export function handleCreateFioriCommand(argv) {
27
+ const logger = getLogger();
30
28
  if (!Array.isArray(argv) || argv.length < 2) {
31
29
  throw Error(`This function must be called from command line interface (cli). Or provide meaningful arguments.`);
32
30
  }
@@ -45,8 +43,8 @@ function handleCreateFioriCommand(argv) {
45
43
  * @returns - commander program
46
44
  */
47
45
  function getCommanderProgram() {
48
- const logger = (0, tracing_1.getLogger)();
49
- const program = new commander_1.Command();
46
+ const logger = getLogger();
47
+ const program = new Command();
50
48
  const version = getVersion();
51
49
  program.description(`Configure features for SAP Fiori applications and projects.`);
52
50
  program.addHelpText('after', `\nExample Usage:
@@ -67,43 +65,43 @@ function getCommanderProgram() {
67
65
  });
68
66
  program.version(version);
69
67
  // Handler for create-fiori generate <feature> ..
70
- const genCommands = (0, generate_1.getGenerateCommands)();
68
+ const genCommands = getGenerateCommands();
71
69
  genCommands.description(`Command group for generating SAP Fiori applications. A subcommand is required.
72
70
  Usage: \`npx --yes @sap-ux/create@latest generate [subcommand] [options]\`
73
71
  The available subcommands are: ${getFeatureSummary(genCommands.commands)}\n`);
74
72
  program.addCommand(genCommands);
75
73
  // Handler for create-fiori add <feature> ..
76
- const addCommands = (0, add_1.getAddCommands)();
74
+ const addCommands = getAddCommands();
77
75
  addCommands.description(`Command group for adding features to existing SAP Fiori applications. A subcommand is required.
78
76
  Usage: \`npx --yes @sap-ux/create@latest add [subcommand] [options]\`
79
77
  The available subcommands are: ${getFeatureSummary(addCommands.commands)}\n`);
80
78
  program.addCommand(addCommands);
81
79
  // Handler for create-fiori convert <feature> ..
82
- const convertCommands = (0, convert_1.getConvertCommands)();
80
+ const convertCommands = getConvertCommands();
83
81
  convertCommands.description(`Command group for converting existing SAP Fiori applications. A subcommand is required.
84
82
  Usage: \`npx --yes @sap-ux/create@latest convert [subcommand] [options]\`
85
83
  The available subcommands are: ${getFeatureSummary(convertCommands.commands)}\n`);
86
84
  program.addCommand(convertCommands);
87
85
  // Handler for create-fiori remove <feature> ..
88
- const removeCommands = (0, remove_1.getRemoveCommands)();
86
+ const removeCommands = getRemoveCommands();
89
87
  removeCommands.description(`Command group for removing features from existing SAP Fiori applications. A subcommand is required.
90
88
  Usage: \`npx --yes @sap-ux/create@latest remove [subcommand] [options]\`
91
89
  The available subcommands are: ${getFeatureSummary(removeCommands.commands)}\n`);
92
90
  program.addCommand(removeCommands);
93
91
  // Handler for create-fiori change <feature> ..
94
- const changeCommands = (0, change_1.getChangeCommands)();
92
+ const changeCommands = getChangeCommands();
95
93
  changeCommands.description(`Command group for changing existing SAP Fiori applications. A subcommand is required.
96
94
  Usage: \`npx --yes @sap-ux/create@latest change [subcommand] [options]\`
97
95
  The available subcommands are: ${getFeatureSummary(changeCommands.commands)}`);
98
96
  program.addCommand(changeCommands);
99
97
  // Handler for create-fiori list <feature> ..
100
- const listCommands = (0, list_1.getListCommands)();
98
+ const listCommands = getListCommands();
101
99
  listCommands.description(`Command group for listing saved resources. A subcommand is required.
102
100
  Usage: \`npx --yes @sap-ux/create@latest list [subcommand] [options]\`
103
101
  The available subcommands are: ${getFeatureSummary(listCommands.commands)}\n`);
104
102
  program.addCommand(listCommands);
105
103
  // Handler for create-fiori get <feature> ..
106
- const getCommands = (0, get_1.getGetCommands)();
104
+ const getCommands = getGetCommands();
107
105
  getCommands.description(`Command group for retrieving saved resources. A subcommand is required.
108
106
  Usage: \`npx --yes @sap-ux/create@latest get [subcommand] [options]\`
109
107
  The available subcommands are: ${getFeatureSummary(getCommands.commands)}\n`);
@@ -155,7 +153,7 @@ function parseCommand(cmd) {
155
153
  * @param cmd - The main Commander program instance.
156
154
  * @returns A JSON string representing the CLI's capabilities.
157
155
  */
158
- function generateJsonSpec(cmd) {
156
+ export function generateJsonSpec(cmd) {
159
157
  const spec = {
160
158
  description: cmd.description(),
161
159
  commands: cmd.commands.map(parseCommand)
@@ -170,10 +168,10 @@ function generateJsonSpec(cmd) {
170
168
  function getVersion() {
171
169
  let version = '';
172
170
  try {
173
- version = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '../../package.json'), { encoding: 'utf8' }).toString()).version;
171
+ version = JSON.parse(readFileSync(join(__dirname, '../../package.json'), { encoding: 'utf8' }).toString()).version;
174
172
  }
175
173
  catch (error) {
176
- const logger = (0, tracing_1.getLogger)();
174
+ const logger = getLogger();
177
175
  logger.warn(`Could not read version from 'package.json'`);
178
176
  logger.debug(error);
179
177
  }
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getListCommands = getListCommands;
4
- const commander_1 = require("commander");
5
- const system_1 = require("./system");
1
+ import { Command } from 'commander';
2
+ import { addSystemListCommand } from './system.js';
6
3
  /**
7
4
  * Return 'create-fiori list *' commands. Commands include also the handler action.
8
5
  *
9
6
  * @returns - commander command containing list <feature> commands
10
7
  */
11
- function getListCommands() {
12
- const listCommands = new commander_1.Command('list');
13
- (0, system_1.addSystemListCommand)(listCommands);
8
+ export function getListCommands() {
9
+ const listCommands = new Command('list');
10
+ addSystemListCommand(listCommands);
14
11
  return listCommands;
15
12
  }
16
13
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSystemListCommand = addSystemListCommand;
4
- const btp_utils_1 = require("@sap-ux/btp-utils");
5
- const store_1 = require("@sap-ux/store");
6
- const logger_1 = require("@sap-ux/logger");
7
- const tracing_1 = require("../../tracing");
1
+ import { isAppStudio } from '@sap-ux/btp-utils';
2
+ import { getService } from '@sap-ux/store';
3
+ import { NullTransport, ToolsLogger } from '@sap-ux/logger';
4
+ import { getLogger } from '../../tracing/index.js';
8
5
  /**
9
6
  * Add the "list system" subcommand to a passed command.
10
7
  * Lists all backend systems saved in the store (~/.fioritools).
@@ -12,7 +9,7 @@ const tracing_1 = require("../../tracing");
12
9
  *
13
10
  * @param cmd - commander command to attach the system subcommand to
14
11
  */
15
- function addSystemListCommand(cmd) {
12
+ export function addSystemListCommand(cmd) {
16
13
  cmd.command('system')
17
14
  .description(`List all back-end systems in the saved system store (\`~/.fioritools\`). Sensitive data, such as passwords and tokens, is never included in the output.\n
18
15
  Example:
@@ -30,17 +27,17 @@ Example:
30
27
  * @param asJson - if true, output as JSON; otherwise print a human-readable list
31
28
  */
32
29
  async function listSystems(asJson) {
33
- const logger = (0, tracing_1.getLogger)();
30
+ const logger = getLogger();
34
31
  try {
35
- if ((0, btp_utils_1.isAppStudio)()) {
32
+ if (isAppStudio()) {
36
33
  logger.error('System management using the CLI is not supported in SAP Business Application Studio. Use the built-in system management instead.');
37
34
  return;
38
35
  }
39
36
  // When emitting JSON, pass a silent logger to getService so that
40
37
  // @sap-ux/store diagnostic messages (e.g. "Using KeyStoreManager…") do
41
38
  // not appear on stdout before the JSON payload and break piped consumers.
42
- const storeLogger = asJson ? new logger_1.ToolsLogger({ transports: [new logger_1.NullTransport()] }) : logger;
43
- const service = await (0, store_1.getService)({
39
+ const storeLogger = asJson ? new ToolsLogger({ transports: [new NullTransport()] }) : logger;
40
+ const service = await getService({
44
41
  entityName: 'system',
45
42
  logger: storeLogger
46
43
  });
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRemoveCommands = getRemoveCommands;
4
- const commander_1 = require("commander");
5
- const mockserver_config_1 = require("./mockserver-config");
6
- const system_1 = require("./system");
1
+ import { Command } from 'commander';
2
+ import { addRemoveMockserverConfigCommand } from './mockserver-config.js';
3
+ import { addSystemRemoveCommand } from './system.js';
7
4
  /**
8
5
  * Return 'create-fiori remove *' commands. Commands include also the handler action.
9
6
  *
10
7
  * @returns - commander command containing remove <feature> commands
11
8
  */
12
- function getRemoveCommands() {
13
- const removeCommands = new commander_1.Command('remove');
14
- (0, mockserver_config_1.addRemoveMockserverConfigCommand)(removeCommands);
15
- (0, system_1.addSystemRemoveCommand)(removeCommands);
9
+ export function getRemoveCommands() {
10
+ const removeCommands = new Command('remove');
11
+ addRemoveMockserverConfigCommand(removeCommands);
12
+ addSystemRemoveCommand(removeCommands);
16
13
  return removeCommands;
17
14
  }
18
15
  //# sourceMappingURL=index.js.map
@@ -1,19 +1,13 @@
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.addRemoveMockserverConfigCommand = addRemoveMockserverConfigCommand;
7
- const prompts_1 = __importDefault(require("prompts"));
8
- const mockserver_config_writer_1 = require("@sap-ux/mockserver-config-writer");
9
- const tracing_1 = require("../../tracing");
10
- const validation_1 = require("../../validation");
1
+ import prompts from 'prompts';
2
+ import { removeMockserverConfig } from '@sap-ux/mockserver-config-writer';
3
+ import { getLogger, setLogLevelVerbose, traceChanges } from '../../tracing/index.js';
4
+ import { hasFileDeletes, validateBasePath } from '../../validation/index.js';
11
5
  /**
12
6
  * Add the "add mockserver config" command to a passed command.
13
7
  *
14
8
  * @param cmd - commander command for adding mockserver config command
15
9
  */
16
- function addRemoveMockserverConfigCommand(cmd) {
10
+ export function addRemoveMockserverConfigCommand(cmd) {
17
11
  cmd.command('mockserver-config [path]')
18
12
  .description(`Removes the configuration for the \`@sap-ux/ui5-middleware-fe-mockserver\` mockserver module.\n
19
13
  Example:
@@ -22,7 +16,7 @@ Example:
22
16
  .option('-f, --force', 'Do not ask for confirmation when deleting files.')
23
17
  .action(async (path, options) => {
24
18
  if (options.verbose === true) {
25
- (0, tracing_1.setLogLevelVerbose)();
19
+ setLogLevelVerbose();
26
20
  }
27
21
  await removeMockserverConfiguration(path || process.cwd(), !!options.force);
28
22
  });
@@ -34,16 +28,16 @@ Example:
34
28
  * @param force - if true, do not ask before deleting files; otherwise ask
35
29
  */
36
30
  async function removeMockserverConfiguration(basePath, force) {
37
- const logger = (0, tracing_1.getLogger)();
31
+ const logger = getLogger();
38
32
  try {
39
33
  logger.debug(`Called remove mockserver-config for path '${basePath}', force is '${force}'`);
40
- await (0, validation_1.validateBasePath)(basePath);
41
- const fs = await (0, mockserver_config_writer_1.removeMockserverConfig)(basePath);
42
- await (0, tracing_1.traceChanges)(fs);
43
- const hasDeletions = (0, validation_1.hasFileDeletes)(fs);
34
+ await validateBasePath(basePath);
35
+ const fs = await removeMockserverConfig(basePath);
36
+ await traceChanges(fs);
37
+ const hasDeletions = hasFileDeletes(fs);
44
38
  let doCommit = true;
45
39
  if (hasDeletions && !force) {
46
- doCommit = (await (0, prompts_1.default)([
40
+ doCommit = (await prompts([
47
41
  {
48
42
  type: 'confirm',
49
43
  name: 'doCommit',
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSystemRemoveCommand = addSystemRemoveCommand;
4
- const btp_utils_1 = require("@sap-ux/btp-utils");
5
- const store_1 = require("@sap-ux/store");
6
- const tracing_1 = require("../../tracing");
1
+ import { isAppStudio } from '@sap-ux/btp-utils';
2
+ import { getService, BackendSystemKey } from '@sap-ux/store';
3
+ import { getLogger } from '../../tracing/index.js';
7
4
  /**
8
5
  * Add the "remove system" subcommand to a passed command.
9
6
  * Removes a saved backend system from the store (~/.fioritools) and deletes its credentials from the OS keychain.
10
7
  *
11
8
  * @param cmd - commander command to attach the system subcommand to
12
9
  */
13
- function addSystemRemoveCommand(cmd) {
10
+ export function addSystemRemoveCommand(cmd) {
14
11
  cmd.command('system')
15
12
  .description(`Remove a saved back-end system from the saved system store (\`~/.fioritools\`). Also deletes any stored credentials in the OS keychain.\n
16
13
  Example:
@@ -29,14 +26,14 @@ Example:
29
26
  * @param client - optional SAP client
30
27
  */
31
28
  async function removeSystem(url, client) {
32
- const logger = (0, tracing_1.getLogger)();
29
+ const logger = getLogger();
33
30
  try {
34
- if ((0, btp_utils_1.isAppStudio)()) {
31
+ if (isAppStudio()) {
35
32
  logger.error('System management using the CLI is not supported in SAP Business Application Studio. Use the built-in system management instead.');
36
33
  return;
37
34
  }
38
- const service = await (0, store_1.getService)({ entityName: 'system' });
39
- const key = new store_1.BackendSystemKey({ url, client });
35
+ const service = await getService({ entityName: 'system' });
36
+ const key = new BackendSystemKey({ url, client });
40
37
  const system = await service.read(key);
41
38
  if (!system) {
42
39
  logger.error(`System not found: ${key.getId()}`);
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from '@sap-ux/logger';
2
- export { promptYUIQuestions } from './prompts';
2
+ export { promptYUIQuestions } from './prompts.js';
3
3
  /**
4
4
  * Run npm install command.
5
5
  *
@@ -1,10 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptYUIQuestions = void 0;
4
- exports.runNpmInstallCommand = runNpmInstallCommand;
5
- const project_access_1 = require("@sap-ux/project-access");
6
- var prompts_1 = require("./prompts");
7
- Object.defineProperty(exports, "promptYUIQuestions", { enumerable: true, get: function () { return prompts_1.promptYUIQuestions; } });
1
+ import { execNpmCommand } from '@sap-ux/project-access';
2
+ export { promptYUIQuestions } from './prompts.js';
8
3
  /**
9
4
  * Run npm install command.
10
5
  *
@@ -13,9 +8,9 @@ Object.defineProperty(exports, "promptYUIQuestions", { enumerable: true, get: fu
13
8
  * @param [options] - optional options
14
9
  * @param [options.logger] - optional logger instance
15
10
  */
16
- function runNpmInstallCommand(basePath, installArgs = [], options) {
11
+ export function runNpmInstallCommand(basePath, installArgs = [], options) {
17
12
  const logger = options?.logger;
18
- (0, project_access_1.execNpmCommand)(['install', ...installArgs], { cwd: basePath, logger: logger })
13
+ execNpmCommand(['install', ...installArgs], { cwd: basePath, logger: logger })
19
14
  .then(() => {
20
15
  logger?.info('npm install completed successfully.');
21
16
  })
@@ -1,13 +1,5 @@
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.filterLabelTypeQuestions = filterLabelTypeQuestions;
7
- exports.convertQuestion = convertQuestion;
8
- exports.promptYUIQuestions = promptYUIQuestions;
9
- const prompts_1 = __importDefault(require("prompts"));
10
- const tracing_1 = require("../tracing");
1
+ import prompts from 'prompts';
2
+ import { getLogger } from '../tracing/index.js';
11
3
  /**
12
4
  * Checks if a property is a function.
13
5
  *
@@ -42,7 +34,7 @@ function mapChoices(choices) {
42
34
  * @returns {Promise<YUIQuestion<T>[]>} A promise that resolves to an array of questions, excluding those with a 'label' type.
43
35
  * @template T - The generic type parameter that extends Answers, used to type the questions array.
44
36
  */
45
- async function filterLabelTypeQuestions(questions) {
37
+ export async function filterLabelTypeQuestions(questions) {
46
38
  return questions.filter((question) => question?.guiOptions?.type !== 'label');
47
39
  }
48
40
  /**
@@ -94,7 +86,7 @@ async function extractMessage(question, answers) {
94
86
  * @param answers previously given answers
95
87
  * @returns question converted to prompts question
96
88
  */
97
- async function convertQuestion(question, answers) {
89
+ export async function convertQuestion(question, answers) {
98
90
  const prompt = {
99
91
  type: QUESTION_TYPE_MAP[question.type ?? 'input'] ?? question.type,
100
92
  name: question.name,
@@ -115,7 +107,7 @@ async function convertQuestion(question, answers) {
115
107
  * @param answers - previously given answers
116
108
  * @returns the answers to the questions
117
109
  */
118
- async function promptYUIQuestions(questions, useDefaults, answers) {
110
+ export async function promptYUIQuestions(questions, useDefaults, answers) {
119
111
  answers ??= {};
120
112
  for (const question of questions) {
121
113
  if (isFunction(question.when) ? await question.when(answers) : question.when !== false) {
@@ -138,7 +130,7 @@ async function promptYUIQuestions(questions, useDefaults, answers) {
138
130
  */
139
131
  async function promptSingleQuestion(answers, question) {
140
132
  const q = await convertQuestion(question, answers);
141
- const answer = await (0, prompts_1.default)(q, {
133
+ const answer = await prompts(q, {
142
134
  onCancel: () => {
143
135
  throw new Error('User canceled the prompt');
144
136
  }
@@ -147,7 +139,7 @@ async function promptSingleQuestion(answers, question) {
147
139
  if (q.type === 'autocomplete') {
148
140
  const valid = await q.validate(answer[question.name]);
149
141
  if (valid !== true) {
150
- (0, tracing_1.getLogger)().warn(valid);
142
+ getLogger().warn(valid);
151
143
  return promptSingleQuestion(answers, question);
152
144
  }
153
145
  }
package/dist/index.js CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const cli_1 = require("./cli");
5
- (0, cli_1.handleCreateFioriCommand)(process.argv);
2
+ import { handleCreateFioriCommand } from './cli/index.js';
3
+ handleCreateFioriCommand(process.argv);
6
4
  //# sourceMappingURL=index.js.map
@@ -1,19 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareJson = compareJson;
4
- exports.compareStrings = compareStrings;
5
- const diff_1 = require("diff");
6
- const chalk_1 = require("chalk");
7
- const logger_1 = require("./logger");
1
+ import { diffJson, diffTrimmedLines } from 'diff';
2
+ import chalk from 'chalk';
3
+ import { getLogger } from './logger.js';
8
4
  /**
9
5
  * Compare two json files.
10
6
  *
11
7
  * @param a - First object to compare
12
8
  * @param b - Second object to compare
13
9
  */
14
- function compareJson(a, b) {
15
- const logger = (0, logger_1.getLogger)();
16
- const diffChanges = (0, diff_1.diffJson)(a, b);
10
+ export function compareJson(a, b) {
11
+ const logger = getLogger();
12
+ const diffChanges = diffJson(a, b);
17
13
  const diffResultString = getDiffResultString(diffChanges);
18
14
  logger.debug(`File changes:\n${diffResultString}`);
19
15
  }
@@ -23,9 +19,9 @@ function compareJson(a, b) {
23
19
  * @param a - First object to compare
24
20
  * @param b - Second object to compare
25
21
  */
26
- function compareStrings(a, b) {
27
- const logger = (0, logger_1.getLogger)();
28
- const diffChanges = (0, diff_1.diffTrimmedLines)(a, b);
22
+ export function compareStrings(a, b) {
23
+ const logger = getLogger();
24
+ const diffChanges = diffTrimmedLines(a, b);
29
25
  const diffResultString = getDiffResultString(diffChanges);
30
26
  logger.debug(`File changes:\n${diffResultString}`);
31
27
  }
@@ -39,13 +35,13 @@ function getDiffResultString(diffChanges) {
39
35
  let diffResults = '';
40
36
  for (const diffChange of diffChanges) {
41
37
  if (diffChange.added) {
42
- diffResults += (0, chalk_1.green)(diffChange.value);
38
+ diffResults += chalk.green(diffChange.value);
43
39
  }
44
40
  else if (diffChange.removed) {
45
- diffResults += (0, chalk_1.red)(diffChange.value);
41
+ diffResults += chalk.red(diffChange.value);
46
42
  }
47
43
  else {
48
- diffResults += (0, chalk_1.grey)(diffChange.value);
44
+ diffResults += chalk.grey(diffChange.value);
49
45
  }
50
46
  }
51
47
  return diffResults;
@@ -1,3 +1,3 @@
1
- export { traceChanges } from './trace';
2
- export { getLogger, setLogLevelVerbose } from './logger';
1
+ export { traceChanges } from './trace.js';
2
+ export { getLogger, setLogLevelVerbose } from './logger.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setLogLevelVerbose = exports.getLogger = exports.traceChanges = void 0;
4
- var trace_1 = require("./trace");
5
- Object.defineProperty(exports, "traceChanges", { enumerable: true, get: function () { return trace_1.traceChanges; } });
6
- var logger_1 = require("./logger");
7
- Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } });
8
- Object.defineProperty(exports, "setLogLevelVerbose", { enumerable: true, get: function () { return logger_1.setLogLevelVerbose; } });
1
+ export { traceChanges } from './trace.js';
2
+ export { getLogger, setLogLevelVerbose } from './logger.js';
9
3
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,5 @@
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.getLogger = getLogger;
7
- exports.setLogLevelVerbose = setLogLevelVerbose;
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const logger_1 = require("@sap-ux/logger");
1
+ import chalk from 'chalk';
2
+ import { ConsoleTransport, LogLevel, ToolsLogger } from '@sap-ux/logger';
10
3
  const levelColor = {
11
4
  warn: 'yellow',
12
5
  error: 'red',
@@ -19,9 +12,9 @@ let logger;
19
12
  *
20
13
  * @returns - Logger
21
14
  */
22
- function getLogger() {
15
+ export function getLogger() {
23
16
  if (!logger) {
24
- logger = new logger_1.ToolsLogger({ transports: [new logger_1.ConsoleTransport()], logPrefix: '' });
17
+ logger = new ToolsLogger({ transports: [new ConsoleTransport()], logPrefix: '' });
25
18
  setCustomFormatter(logger);
26
19
  }
27
20
  return logger;
@@ -39,7 +32,8 @@ function setCustomFormatter(logger) {
39
32
  const consoleTransport = transports.find((t) => t?.name === 'console');
40
33
  if (consoleTransport?.format) {
41
34
  consoleTransport.format.transform = (info) => {
42
- const colorFn = levelColor[info.level] ? chalk_1.default.keyword(levelColor[info.level]) : (m) => m;
35
+ // Map level colors to chalk functions
36
+ const colorFn = levelColor[info.level] ? chalk[levelColor[info.level]] : (m) => m;
43
37
  const formattedMessage = colorFn ? colorFn(info.message) : info.message;
44
38
  const symbol = Object.getOwnPropertySymbols(info).find((s) => s?.description === 'message');
45
39
  if (symbol) {
@@ -55,12 +49,12 @@ function setCustomFormatter(logger) {
55
49
  * @param logLevel - see @sap-ux/logger -> LogLevel
56
50
  */
57
51
  function updateLogLevel(logLevel) {
58
- logger = new logger_1.ToolsLogger({ logLevel, transports: [new logger_1.ConsoleTransport()], logPrefix: '' });
52
+ logger = new ToolsLogger({ logLevel, transports: [new ConsoleTransport()], logPrefix: '' });
59
53
  }
60
54
  /**
61
55
  * Set the log level to verbose (debug).
62
56
  */
63
- function setLogLevelVerbose() {
64
- updateLogLevel(logger_1.LogLevel.Debug);
57
+ export function setLogLevelVerbose() {
58
+ updateLogLevel(LogLevel.Debug);
65
59
  }
66
60
  //# sourceMappingURL=logger.js.map
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.traceChanges = traceChanges;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const compare_1 = require("./compare");
7
- const logger_1 = require("./logger");
1
+ import { existsSync, promises } from 'node:fs';
2
+ import { extname } from 'node:path';
3
+ import { compareStrings, compareJson } from './compare.js';
4
+ import { getLogger } from './logger.js';
8
5
  /**
9
6
  * Compare changes from mem-fs-editor and write to logger.
10
7
  *
11
8
  * @param fs - mem-fs-editor
12
9
  */
13
- async function traceChanges(fs) {
10
+ export async function traceChanges(fs) {
14
11
  const changedFiles = fs.dump() || {};
15
- const logger = (0, logger_1.getLogger)();
12
+ const logger = getLogger();
16
13
  for (const changedFile in changedFiles) {
17
14
  const fileStat = changedFiles[changedFile];
18
15
  if (fileStat.state === 'deleted') {
@@ -20,26 +17,26 @@ async function traceChanges(fs) {
20
17
  continue;
21
18
  }
22
19
  const memContent = fileStat.contents;
23
- if (!(0, node_fs_1.existsSync)(changedFile)) {
20
+ if (!existsSync(changedFile)) {
24
21
  logger.info(`File '${changedFile}' added`);
25
22
  logger.debug(`File content:\n${memContent}`);
26
23
  continue;
27
24
  }
28
- const discContent = await node_fs_1.promises.readFile(changedFile, 'utf-8');
25
+ const discContent = await promises.readFile(changedFile, 'utf-8');
29
26
  if (discContent === memContent) {
30
27
  logger.info(`File '${changedFile}' unchanged`);
31
28
  logger.debug(`File content:\n${memContent}`);
32
29
  continue;
33
30
  }
34
31
  logger.info(`File '${changedFile}' modified`);
35
- const fileExtension = (0, node_path_1.extname)(changedFile).toLowerCase();
32
+ const fileExtension = extname(changedFile).toLowerCase();
36
33
  switch (fileExtension) {
37
34
  case '.json': {
38
- (0, compare_1.compareJson)(JSON.parse(discContent), JSON.parse(memContent));
35
+ compareJson(JSON.parse(discContent), JSON.parse(memContent));
39
36
  break;
40
37
  }
41
38
  case '.yaml': {
42
- (0, compare_1.compareStrings)(discContent, memContent);
39
+ compareStrings(discContent, memContent);
43
40
  break;
44
41
  }
45
42
  default:
@@ -1,2 +1,2 @@
1
- export { hasFileDeletes, validateBasePath, validateCloudAdpProject, validateAdpAppType } from './validation';
1
+ export { hasFileDeletes, validateBasePath, validateCloudAdpProject, validateAdpAppType } from './validation.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateAdpAppType = exports.validateCloudAdpProject = exports.validateBasePath = exports.hasFileDeletes = void 0;
4
- var validation_1 = require("./validation");
5
- Object.defineProperty(exports, "hasFileDeletes", { enumerable: true, get: function () { return validation_1.hasFileDeletes; } });
6
- Object.defineProperty(exports, "validateBasePath", { enumerable: true, get: function () { return validation_1.validateBasePath; } });
7
- Object.defineProperty(exports, "validateCloudAdpProject", { enumerable: true, get: function () { return validation_1.validateCloudAdpProject; } });
8
- Object.defineProperty(exports, "validateAdpAppType", { enumerable: true, get: function () { return validation_1.validateAdpAppType; } });
1
+ export { hasFileDeletes, validateBasePath, validateCloudAdpProject, validateAdpAppType } from './validation.js';
9
2
  //# sourceMappingURL=index.js.map