@sap-ux/create 1.2.1 → 1.3.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/README.md CHANGED
@@ -34,7 +34,7 @@ Command group for generating SAP Fiori applications. A subcommand is required.
34
34
 
35
35
  Usage: `npx --yes @sap-ux/create@latest generate [subcommand] [options]`
36
36
 
37
- The available subcommands are: `adaptation-project`
37
+ The available subcommands are: `adaptation-project` and `opa5-tests`
38
38
 
39
39
 
40
40
  --------------------------------
@@ -62,6 +62,21 @@ Options:
62
62
 
63
63
  --------------------------------
64
64
 
65
+ ## [`generate opa5-tests`](#generate-opa5-tests)
66
+
67
+ Generate OPA5 integration tests for an existing SAP Fiori elements (OData V4) application.
68
+
69
+ Example:
70
+
71
+ `npx --yes @sap-ux/create@latest generate opa5-tests`
72
+
73
+ Options:
74
+ - `-t, --typescript` - Force generation of TypeScript test files. Otherwise, TypeScript is auto-detected from the presence of a `tsconfig.json`.
75
+ - `-s, --simulate` - Simulate only. Do not write. Also, sets `--verbose`
76
+ - `-v, --verbose` - Show verbose information.
77
+
78
+ --------------------------------
79
+
65
80
  ## [`add`](#add)
66
81
 
67
82
  Command group for adding features to existing SAP Fiori applications. A subcommand is required.
@@ -1,11 +1,13 @@
1
1
  import { Command } from 'commander';
2
2
  import { addGenerateAdaptationProjectCommand } from './adaptation-project.js';
3
+ import { addGenerateOpa5TestsCommand } from './opa5-tests.js';
3
4
  /**
4
5
  * @returns 'generate *' commands. Commands include also the handler action.
5
6
  */
6
7
  export function getGenerateCommands() {
7
8
  const genCommands = new Command('generate');
8
9
  addGenerateAdaptationProjectCommand(genCommands);
10
+ addGenerateOpa5TestsCommand(genCommands);
9
11
  return genCommands;
10
12
  }
11
13
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Add the "generate opa5-tests" command to a passed command.
4
+ *
5
+ * @param cmd - commander command for generating OPA5 tests
6
+ */
7
+ export declare function addGenerateOpa5TestsCommand(cmd: Command): void;
8
+ //# sourceMappingURL=opa5-tests.d.ts.map
@@ -0,0 +1,58 @@
1
+ import { createApplicationAccess, getMinUI5VersionAsArray } from '@sap-ux/project-access';
2
+ import { generateOPAFiles } from '@sap-ux/ui5-test-writer';
3
+ import { getLogger, traceChanges, setLogLevelVerbose } from '../../tracing/index.js';
4
+ import { validateBasePath } from '../../validation/index.js';
5
+ /**
6
+ * Add the "generate opa5-tests" command to a passed command.
7
+ *
8
+ * @param cmd - commander command for generating OPA5 tests
9
+ */
10
+ export function addGenerateOpa5TestsCommand(cmd) {
11
+ cmd.command('opa5-tests [path]')
12
+ .description(`Generate OPA5 integration tests for an existing SAP Fiori elements (OData V4) application.\n
13
+ Example:
14
+ \`npx --yes @sap-ux/create@latest generate opa5-tests\``)
15
+ .option('-t, --typescript', 'Force generation of TypeScript test files. Otherwise, TypeScript is auto-detected from the presence of a `tsconfig.json`.')
16
+ .option('-s, --simulate', 'Simulate only. Do not write. Also, sets `--verbose`')
17
+ .option('-v, --verbose', 'Show verbose information.')
18
+ .action(async (path, options) => {
19
+ if (options.verbose === true || options.simulate) {
20
+ setLogLevelVerbose();
21
+ }
22
+ await generateOpa5Tests(path || process.cwd(), !!options.simulate, !!options.typescript);
23
+ });
24
+ }
25
+ /**
26
+ * Generates OPA5 integration tests for an existing Fiori elements application.
27
+ *
28
+ * @param basePath - path to the application root
29
+ * @param simulate - if true, do not write but just show what would be changed; otherwise write
30
+ * @param forceTypeScript - if true, force TypeScript test files instead of auto-detecting
31
+ */
32
+ async function generateOpa5Tests(basePath, simulate, forceTypeScript) {
33
+ const logger = getLogger();
34
+ try {
35
+ logger.debug(`Called generate opa5-tests for path '${basePath}', simulate is '${simulate}'`);
36
+ await validateBasePath(basePath);
37
+ const appAccess = await createApplicationAccess(basePath);
38
+ const manifest = await appAccess.readManifest();
39
+ const versions = getMinUI5VersionAsArray(manifest);
40
+ const ui5Version = versions.find((v) => v.startsWith('1.')) ?? versions[0] ?? '';
41
+ const fs = await generateOPAFiles(basePath, {
42
+ ...(forceTypeScript ? { enableTypeScript: true } : {}),
43
+ ...(ui5Version ? { ui5Version } : {})
44
+ }, undefined, undefined, logger, true);
45
+ if (!simulate) {
46
+ await new Promise((resolve) => fs.commit(resolve));
47
+ logger.info(`Changes written.`);
48
+ }
49
+ else {
50
+ await traceChanges(fs);
51
+ }
52
+ }
53
+ catch (error) {
54
+ logger.error(`Error while executing generate opa5-tests '${error instanceof Error ? error.message : String(error)}'`);
55
+ logger.debug(error instanceof Error ? error : String(error));
56
+ }
57
+ }
58
+ //# sourceMappingURL=opa5-tests.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/create",
3
3
  "description": "SAP Fiori tools module to add or remove features",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -35,21 +35,22 @@
35
35
  "prompts": "2.4.2",
36
36
  "@sap-ux/abap-deploy-config-inquirer": "2.0.36",
37
37
  "@sap-ux/abap-deploy-config-writer": "1.0.20",
38
- "@sap-ux/adp-tooling": "1.0.43",
39
38
  "@sap-ux/btp-utils": "2.0.6",
40
39
  "@sap-ux/app-config-writer": "1.1.15",
41
40
  "@sap-ux/cap-config-writer": "1.0.28",
42
41
  "@sap-ux/inquirer-common": "1.0.31",
42
+ "@sap-ux/adp-tooling": "1.0.44",
43
43
  "@sap-ux/logger": "1.0.3",
44
44
  "@sap-ux/mockserver-config-writer": "1.0.15",
45
45
  "@sap-ux/odata-service-writer": "1.0.18",
46
- "@sap-ux/preview-middleware": "1.2.0",
46
+ "@sap-ux/preview-middleware": "1.2.1",
47
47
  "@sap-ux/project-access": "2.1.10",
48
48
  "@sap-ux/project-input-validator": "1.0.15",
49
49
  "@sap-ux/system-access": "1.0.10",
50
50
  "@sap-ux/store": "2.0.6",
51
51
  "@sap-ux/ui5-config": "1.0.7",
52
- "@sap-ux/flp-config-inquirer": "1.0.43",
52
+ "@sap-ux/flp-config-inquirer": "1.0.44",
53
+ "@sap-ux/ui5-test-writer": "1.7.2",
53
54
  "@sap-ux/nodejs-utils": "1.0.9",
54
55
  "@sap-ux/axios-extension": "2.0.8"
55
56
  },