@cbs-consulting/generator-btp 1.0.3 → 1.1.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.
@@ -25,6 +25,10 @@ module.exports = class extends Generator {
25
25
  name: "Add best practices to existing UI5 project",
26
26
  value: "ui5",
27
27
  },
28
+ {
29
+ name: "Add devcontainer configuration",
30
+ value: "devcontainer",
31
+ },
28
32
  ],
29
33
  },
30
34
  ]);
@@ -37,6 +41,8 @@ module.exports = class extends Generator {
37
41
  this.composeWith(resolve(__dirname, "../cap/index.js"));
38
42
  } else if (this.kind === "ui5") {
39
43
  this.composeWith(resolve(__dirname, "../ui5/index.js"));
44
+ } else if (this.kind === "devcontainer") {
45
+ this.composeWith(resolve(__dirname, "../devcontainer/index.js"));
40
46
  } else {
41
47
  this.log(chalk.red("Unknown selection"));
42
48
  }
@@ -98,6 +98,7 @@ module.exports = class extends Generator {
98
98
  writing() {
99
99
  this.log(chalk.bold("\n✍️ Writing files..."));
100
100
 
101
+ // 1) Copy CAP-specific templates (excluding devcontainer)
101
102
  this.sourceRoot(join(__dirname, "templates"));
102
103
  globSync("**", {
103
104
  cwd: this.sourceRoot(),
@@ -106,6 +107,11 @@ module.exports = class extends Generator {
106
107
  let sOrigin;
107
108
  let sTarget;
108
109
 
110
+ // Skip devcontainer files - they come from the devcontainer generator
111
+ if (fileName.startsWith("_.devcontainer/")) {
112
+ return;
113
+ }
114
+
109
115
  if (fileName === "azure-pipelines.yaml" && !this.answers.useAzureDevOps) {
110
116
  return;
111
117
  }
@@ -118,7 +124,25 @@ module.exports = class extends Generator {
118
124
  this.fs.copyTpl(sOrigin, sTarget, this.answers);
119
125
  });
120
126
 
121
- // 2) Merge additions into existing files (scripting.txt is excluded by design)
127
+ // 2) Copy devcontainer files from the devcontainer generator
128
+ const devcontainerTemplatesPath = resolve(
129
+ __dirname,
130
+ "../devcontainer/templates",
131
+ );
132
+ this.sourceRoot(devcontainerTemplatesPath);
133
+ globSync("**", {
134
+ cwd: this.sourceRoot(),
135
+ nodir: true,
136
+ }).forEach((fileName) => {
137
+ const sOrigin = join(devcontainerTemplatesPath, fileName);
138
+ const sTarget = this.destinationPath(
139
+ fileName.replace(/^_/, "").replace(/\/_/, "/"),
140
+ );
141
+
142
+ this.fs.copyTpl(sOrigin, sTarget, this.answers);
143
+ });
144
+
145
+ // 3) Merge additions into existing files (scripting.txt is excluded by design)
122
146
  // package.json
123
147
  const destPkgPath = this.destinationPath("package.json");
124
148
  const srcPkgPath = join(this._addRoot, "package.json");
@@ -0,0 +1,78 @@
1
+ const chalk = require("chalk");
2
+ const glob = require("glob");
3
+ const fs = require("node:fs");
4
+ const { join, resolve } = require("node:path");
5
+ const Generator = require("yeoman-generator");
6
+ const globSync = glob.globSync || glob.sync;
7
+
8
+ module.exports = class extends Generator {
9
+ _tplRoot = resolve(__dirname, "./templates");
10
+
11
+ async initializing() {
12
+ const aPrompt = [];
13
+
14
+ aPrompt.push(
15
+ {
16
+ type: "input",
17
+ name: "projectName",
18
+ message: "Enter the project name:",
19
+ validate(sInput) {
20
+ if (sInput.length > 0) {
21
+ return true;
22
+ }
23
+ return "Project name must not be empty.";
24
+ },
25
+ default: "My Project",
26
+ },
27
+ {
28
+ type: "input",
29
+ name: "customerName",
30
+ message: "Enter the customer's name:",
31
+ validate(sInput) {
32
+ if (sInput.length > 0) {
33
+ return true;
34
+ }
35
+ return "Customer name must not be empty.";
36
+ },
37
+ default: "My Customer",
38
+ },
39
+ );
40
+
41
+ const answers = await this.prompt(aPrompt);
42
+
43
+ answers.projectNameNormalized = answers.projectName
44
+ .toLowerCase()
45
+ .replace(/\s+/g, "-");
46
+ answers.customerNameNormalized = answers.customerName
47
+ .toLowerCase()
48
+ .replace(/\s+/g, "-");
49
+ this.answers = answers;
50
+ }
51
+
52
+ writing() {
53
+ this.log(chalk.bold("\n✍️ Writing .devcontainer files..."));
54
+
55
+ this.sourceRoot(join(__dirname, "templates"));
56
+ globSync("**", {
57
+ cwd: this.sourceRoot(),
58
+ nodir: true,
59
+ }).forEach((fileName) => {
60
+ let sOrigin;
61
+ let sTarget;
62
+
63
+ sOrigin = this.templatePath(fileName);
64
+ sTarget = this.destinationPath(
65
+ fileName.replace(/^_/, "").replace(/\/_/, "/"),
66
+ );
67
+
68
+ this.fs.copyTpl(sOrigin, sTarget, this.answers);
69
+ });
70
+ }
71
+
72
+ end() {
73
+ this.log(chalk.bold.green("\n✅ Dev container configuration added."));
74
+ this.log("Next steps:");
75
+ this.log("1) Review the .devcontainer folder.");
76
+ this.log("2) Customize the Dockerfile and devcontainer.json as needed.");
77
+ }
78
+ };
@@ -0,0 +1 @@
1
+ FROM cbsgroupdocker/cbs-default:latest
@@ -1,6 +1,6 @@
1
1
  {
2
2
  // Container configuration name - identifies this dev container setup
3
- "name": "<%= customerName %> - <%= projectName %>",
3
+ "name": "<%= customerName %> - <%= projectName %>",
4
4
 
5
5
  // Build configuration - specifies how to build the container
6
6
  "build": {
@@ -9,7 +9,9 @@
9
9
  },
10
10
 
11
11
  // Name docker container
12
- "runArgs": ["--name=<%= customerNameNormalized %>.<%= projectNameNormalized %>"],
12
+ "runArgs": [
13
+ "--name=<%= customerNameNormalized %>.<%= projectNameNormalized %>"
14
+ ],
13
15
 
14
16
  // Post-create command to set up npm authentication and install dependencies
15
17
  "postCreateCommand": "bash .devcontainer/post-create.sh",
@@ -21,7 +23,7 @@
21
23
  // Extensions automatically installed in the container
22
24
  // These are isolated from your local VS Code installation
23
25
  "extensions": [
24
- // ====================
26
+ // ====================
25
27
  // General
26
28
  // ====================
27
29
  // GitHub Copilot
@@ -65,12 +67,11 @@
65
67
  "meganrogge.template-string-converter",
66
68
  // display errors inline
67
69
  "usernamehw.errorlens",
68
- //live share VS code
70
+ //live share VS code
69
71
  "MS-vsliveshare.vsliveshare",
70
72
  // show package.json dependencies updates
71
73
  "codeandstuff.package-json-upgrade",
72
74
 
73
-
74
75
  // ====================
75
76
  // CAP
76
77
  // ====================
@@ -154,7 +155,7 @@
154
155
  // ====================
155
156
  "cSpell.language": "en,de-DE"
156
157
  },
157
-
158
+
158
159
  // MCP server configurations
159
160
  "mcp": {
160
161
  "servers": {
@@ -18,4 +18,4 @@ echo "✓ Azure extensions installed successfully!"
18
18
  # Update global npm packages
19
19
  echo "Updating global npm packages... (this can take a few minutes)"
20
20
  sudo npm update -g
21
- echo "✓ Global npm packages updated successfully!"
21
+ echo "✓ Global npm packages updated successfully!"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cbs-consulting/generator-btp",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Yeoman generator for bootstrapping CAP/UI5 projects with TypeScript, ESLint, and other essential configurations",
5
5
  "main": "generators/app/index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- FROM cbsgroupdocker/cbs-default:latest