pro-cpp-cli-core 1.0.5 → 1.0.6

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 (2) hide show
  1. package/index.js +42 -17
  2. package/package.json +9 -5
package/index.js CHANGED
@@ -4,11 +4,14 @@
4
4
  * PRO C++ CLI Core (With C++20 Modules Topological Sorter)
5
5
  * FIX: Restored initProject!
6
6
  * FIX: Smart post-build artifact routing to .build/ directory!
7
+ * NEW: Build time measurement using performance.now()
8
+ * NEW: Native ANSI terminal colors for PRO Developer Experience
7
9
  */
8
10
 
9
11
  const { execSync, spawn } = require('child_process');
10
12
  const fs = require('fs');
11
13
  const path = require('path');
14
+ const { performance } = require('perf_hooks');
12
15
 
13
16
  const [,, command, ...args] = process.argv;
14
17
  let currentAppProcess = null;
@@ -16,6 +19,17 @@ let watchTimeout = null;
16
19
 
17
20
  const BUILD_DIR = path.join(process.cwd(), '.build');
18
21
 
22
+ // ANSI Color codes for a beautiful console UI (Zero dependencies!)
23
+ const colors = {
24
+ reset: "\x1b[0m",
25
+ cyan: "\x1b[36m",
26
+ green: "\x1b[32m",
27
+ yellow: "\x1b[33m",
28
+ red: "\x1b[31m",
29
+ gray: "\x1b[90m",
30
+ bold: "\x1b[1m"
31
+ };
32
+
19
33
  function runSyncCommand(cmd) {
20
34
  try {
21
35
  execSync(cmd, { stdio: 'inherit' });
@@ -52,7 +66,7 @@ function getSortedCppFiles() {
52
66
  for (const file of files) {
53
67
  const filePath = path.join(dir, file);
54
68
  if (fs.statSync(filePath).isDirectory()) {
55
- // ИГНОРИРУЕМ ПАПКУ .build, ЧТОБЫ ВОЧЕР НЕ СОШЕЛ С УМА
69
+ // Ignore .build directory so watcher doesn't loop
56
70
  if (file !== 'node_modules' && file !== '.vscode' && file !== '.build') {
57
71
  scanDir(filePath);
58
72
  }
@@ -95,7 +109,7 @@ function getSortedCppFiles() {
95
109
  }
96
110
 
97
111
  function initProject() {
98
- console.log("🚀 Initializing PRO C++ Project (C++20 Modules)...");
112
+ console.log(`${colors.cyan}${colors.bold}🚀 Initializing PRO C++ Project (C++20 Modules)...${colors.reset}`);
99
113
  const vscodeDir = path.join(process.cwd(), '.vscode');
100
114
  if (!fs.existsSync(vscodeDir)) fs.mkdirSync(vscodeDir);
101
115
 
@@ -125,7 +139,7 @@ function initProject() {
125
139
  "compilerArgs": [
126
140
  "/std:c++20",
127
141
  "/experimental:module",
128
- "/ifcSearchDir", // Указываем IDE, где искать .ifc файлы!
142
+ "/ifcSearchDir",
129
143
  "${workspaceFolder}/.build"
130
144
  ]
131
145
  }],
@@ -146,16 +160,16 @@ function initProject() {
146
160
  // 4. main.cpp template
147
161
  const mainCppPath = path.join(process.cwd(), 'main.cpp');
148
162
  if (!fs.existsSync(mainCppPath)) {
149
- fs.writeFileSync(mainCppPath, `import std.core;\n// C++20 Modules ready!\nint main() { return 0; }`);
163
+ fs.writeFileSync(mainCppPath, `import std.core;\n// C++20 Modules ready!\nint main() {\n return 0;\n}`);
150
164
  }
151
165
 
152
- console.log("✅ Ready! .vscode configs created. IntelliSense is pointed to .build/");
166
+ console.log(`${colors.green}✅ Ready! .vscode configs created. IntelliSense is pointed to .build/${colors.reset}`);
153
167
  }
154
168
 
155
169
  function buildAndRun() {
156
170
  const cppFiles = getSortedCppFiles();
157
171
  if (!cppFiles) {
158
- console.error("❌ Error: No .cpp or .ixx files found!");
172
+ console.error(`${colors.red}❌ Error: No .cpp or .ixx files found!${colors.reset}`);
159
173
  return;
160
174
  }
161
175
 
@@ -165,13 +179,20 @@ function buildAndRun() {
165
179
 
166
180
  const outputExeName = `app_build_${Date.now()}.exe`;
167
181
 
168
- console.log(`\n🔨 Compiling with SMART DEPENDENCY GRAPH...`);
182
+ console.log(`\n${colors.cyan}🔨 Compiling with SMART DEPENDENCY GRAPH...${colors.reset}`);
169
183
 
170
- // Компилируем чисто, без странных флагов
184
+ // Clean compile command, no weird flags
171
185
  const compileCmd = `cl.exe /std:c++20 /nologo /EHsc ${cppFiles} /Fe"${outputExeName}"`;
172
186
 
187
+ // Start the timer!
188
+ const startTime = performance.now();
189
+
173
190
  if (runSyncCommand(compileCmd)) {
174
- // МАГИЯ ПЕРЕНОСА: Двигаем все созданные файлы в папку .build
191
+ // Stop the timer!
192
+ const endTime = performance.now();
193
+ const buildTime = ((endTime - startTime) / 1000).toFixed(2);
194
+
195
+ // Move all artifacts to .build folder
175
196
  const files = fs.readdirSync(process.cwd());
176
197
  files.forEach(file => {
177
198
  if (file.endsWith('.obj') || file.endsWith('.ifc') || file.endsWith('.pdb') || file.endsWith('.ilk') || file === outputExeName) {
@@ -181,29 +202,31 @@ function buildAndRun() {
181
202
  }
182
203
  });
183
204
 
184
- console.log(`🟢 RUNNING -> .build\\${outputExeName}\n` + "-".repeat(40));
205
+ console.log(`${colors.green}${colors.bold}⚡ [Success] Compiled in ${buildTime}s${colors.reset}`);
206
+ console.log(`${colors.yellow}🟢 RUNNING -> .build\\${outputExeName}${colors.reset}\n` + `${colors.gray}${"-".repeat(40)}${colors.reset}`);
185
207
 
186
- // Запускаем из папки .build
208
+ // Run from .build folder
187
209
  currentAppProcess = spawn(`.\\.build\\${outputExeName}`, [], { shell: true, stdio: 'inherit' });
188
210
  currentAppProcess.on('close', (code) => {
189
- if (code !== null) console.log("-".repeat(40) + `\n🛑 Process exited with code ${code}`);
211
+ if (code !== null) console.log(`${colors.gray}${"-".repeat(40)}${colors.reset}\n${colors.red}🛑 Process exited with code ${code}${colors.reset}`);
190
212
  });
191
213
  } else {
192
- console.log(`\n❌ BUILD FAILED`);
214
+ console.log(`\n${colors.red}${colors.bold}❌ BUILD FAILED${colors.reset}`);
193
215
  }
194
216
  }
195
217
 
196
218
  function watchProject() {
197
- console.log("👀 PRO C++ Watcher Started (Mode: Smart C++20 Modules)");
219
+ console.clear();
220
+ console.log(`${colors.cyan}${colors.bold}👀 PRO C++ Watcher Started (Mode: Smart C++20 Modules)${colors.reset}`);
198
221
  buildAndRun();
199
222
 
200
223
  fs.watch(process.cwd(), { recursive: true }, (eventType, filename) => {
201
- // Игнорируем всё, что происходит внутри папки .build
224
+ // Ignore changes inside .build to prevent infinite loops
202
225
  if (filename && (filename.endsWith('.cpp') || filename.endsWith('.ixx') || filename.endsWith('.h')) && !filename.includes('.build')) {
203
226
  clearTimeout(watchTimeout);
204
227
  watchTimeout = setTimeout(() => {
205
228
  console.clear();
206
- console.log(`[${new Date().toLocaleTimeString()}] Change detected: ${filename}`);
229
+ console.log(`${colors.gray}[${new Date().toLocaleTimeString()}] Change detected: ${filename}${colors.reset}`);
207
230
  buildAndRun();
208
231
  }, 300);
209
232
  }
@@ -214,5 +237,7 @@ switch (command) {
214
237
  case 'init': initProject(); break;
215
238
  case 'run': buildAndRun(); break;
216
239
  case 'watch': watchProject(); break;
217
- default: console.log("🛠️ PRO CPP CLI\nUsage: procpp <init|run|watch>"); break;
240
+ default:
241
+ console.log(`${colors.bold}🛠️ PRO CPP CLI${colors.reset}\nUsage: procpp <init|run|watch>`);
242
+ break;
218
243
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-cpp-cli-core",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/anton-po-github/pro-cpp-cli-core.git"
@@ -9,10 +9,10 @@
9
9
  "url": "https://github.com/anton-po-github/pro-cpp-cli-core/issues"
10
10
  },
11
11
  "homepage": "https://github.com/anton-po-github/pro-cpp-cli-core#readme",
12
- "description": "The ultimate C++ Developer Experience for Windows",
12
+ "description": "The ultimate C++ Developer Experience for Windows. Zero config, hot-reload, C++20 Modules support.",
13
13
  "main": "index.js",
14
14
  "bin": {
15
- "procpp": "index.js"
15
+ "procpp": "./index.js"
16
16
  },
17
17
  "scripts": {
18
18
  "start": "node index.js"
@@ -22,8 +22,12 @@
22
22
  "c++",
23
23
  "cli",
24
24
  "watch",
25
- "build"
25
+ "build",
26
+ "hot-reload",
27
+ "c++20",
28
+ "modules",
29
+ "msvc"
26
30
  ],
27
31
  "author": "PRO Developer",
28
32
  "license": "MIT"
29
- }
33
+ }