@cbs-consulting/generator-btp 1.2.5 → 1.2.7
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { expect } from "vitest";
|
|
3
4
|
import assert from "yeoman-assert";
|
|
4
5
|
import * as helpers from "yeoman-test";
|
|
5
6
|
import { assertDevcontainerTemplating } from "../../__tests__/helpers.js";
|
|
@@ -38,37 +39,41 @@ describe("generator-btp:cap", () => {
|
|
|
38
39
|
scenario: "with Azure DevOps enabled",
|
|
39
40
|
projectName: "Test CAP Project",
|
|
40
41
|
customerName: "Test Customer",
|
|
41
|
-
dbSchema: "
|
|
42
|
+
dbSchema: "TEST_CAP_PROJECT",
|
|
42
43
|
useAzureDevOps: true,
|
|
43
44
|
expectedProjectNormalized: "test-cap-project",
|
|
44
45
|
expectedCustomerNormalized: "test-customer",
|
|
46
|
+
expectedDbSchema: "TEST_CAP_PROJECT",
|
|
45
47
|
},
|
|
46
48
|
{
|
|
47
49
|
scenario: "without Azure DevOps",
|
|
48
50
|
projectName: "No Azure Project",
|
|
49
51
|
customerName: "My Customer",
|
|
50
|
-
dbSchema:
|
|
52
|
+
dbSchema: null,
|
|
51
53
|
useAzureDevOps: false,
|
|
52
54
|
expectedProjectNormalized: "no-azure-project",
|
|
53
55
|
expectedCustomerNormalized: "my-customer",
|
|
56
|
+
expectedDbSchema: "NO_AZURE_PROJECT",
|
|
54
57
|
},
|
|
55
58
|
{
|
|
56
59
|
scenario: "with uppercase names",
|
|
57
60
|
projectName: "UPPERCASE PROJECT",
|
|
58
61
|
customerName: "UPPERCASE CUSTOMER",
|
|
59
|
-
dbSchema:
|
|
62
|
+
dbSchema: null,
|
|
60
63
|
useAzureDevOps: false,
|
|
61
64
|
expectedProjectNormalized: "uppercase-project",
|
|
62
65
|
expectedCustomerNormalized: "uppercase-customer",
|
|
66
|
+
expectedDbSchema: "UPPERCASE_PROJECT",
|
|
63
67
|
},
|
|
64
68
|
{
|
|
65
69
|
scenario: "with multiple spaces",
|
|
66
70
|
projectName: "Multi Space Project",
|
|
67
71
|
customerName: "Multi Space Customer",
|
|
68
|
-
dbSchema:
|
|
72
|
+
dbSchema: null,
|
|
69
73
|
useAzureDevOps: true,
|
|
70
74
|
expectedProjectNormalized: "multi-space-project",
|
|
71
75
|
expectedCustomerNormalized: "multi-space-customer",
|
|
76
|
+
expectedDbSchema: "MULTI_SPACE_PROJECT",
|
|
72
77
|
},
|
|
73
78
|
])(
|
|
74
79
|
"$scenario",
|
|
@@ -79,6 +84,7 @@ describe("generator-btp:cap", () => {
|
|
|
79
84
|
useAzureDevOps,
|
|
80
85
|
expectedProjectNormalized,
|
|
81
86
|
expectedCustomerNormalized,
|
|
87
|
+
expectedDbSchema,
|
|
82
88
|
}) => {
|
|
83
89
|
let runResult;
|
|
84
90
|
|
|
@@ -120,7 +126,7 @@ describe("generator-btp:cap", () => {
|
|
|
120
126
|
it("should store and normalize inputs correctly", () => {
|
|
121
127
|
expect(runResult.generator.answers.projectName).toBe(projectName);
|
|
122
128
|
expect(runResult.generator.answers.customerName).toBe(customerName);
|
|
123
|
-
expect(runResult.generator.answers.dbSchema).toBe(
|
|
129
|
+
expect(runResult.generator.answers.dbSchema).toBe(expectedDbSchema);
|
|
124
130
|
expect(runResult.generator.answers.useAzureDevOps).toBe(useAzureDevOps);
|
|
125
131
|
expect(runResult.generator.answers.projectNameNormalized).toBe(
|
|
126
132
|
expectedProjectNormalized,
|
package/generators/cap/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from "chalk";
|
|
|
2
2
|
import { globSync } from "glob";
|
|
3
3
|
import mergewith from "lodash.mergewith";
|
|
4
4
|
import fs from "node:fs";
|
|
5
|
-
import { join, resolve
|
|
5
|
+
import { dirname, join, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import Generator from "yeoman-generator";
|
|
8
8
|
import { mergeArray, readJsonC, readJsonCSafe } from "../../utils/jsonFile.js";
|
|
@@ -53,7 +53,14 @@ export default class extends Generator {
|
|
|
53
53
|
}
|
|
54
54
|
return "Database schema name must not be empty.";
|
|
55
55
|
},
|
|
56
|
-
default
|
|
56
|
+
default(answers) {
|
|
57
|
+
// Use project name in uppercase with underscores instead of special characters
|
|
58
|
+
return answers.projectName
|
|
59
|
+
.toUpperCase()
|
|
60
|
+
.replace(/[^A-Z0-9]/g, '_')
|
|
61
|
+
.replace(/_+/g, '_') // Replace multiple underscores with single underscore
|
|
62
|
+
.replace(/^_|_$/g, ''); // Remove leading/trailing underscores
|
|
63
|
+
},
|
|
57
64
|
},
|
|
58
65
|
{
|
|
59
66
|
type: "confirm",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cbs-consulting/generator-btp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yeoman generator for bootstrapping CAP/UI5 projects with TypeScript, ESLint, and other essential configurations",
|
|
6
6
|
"main": "generators/app/index.js",
|