@hed-hog/cli 0.0.27 ā 0.0.28
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/dist/package.json +1 -1
- package/dist/src/app.module.js +8 -0
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/commands/dev.command/library-version.subcommand.d.ts +10 -0
- package/dist/src/commands/dev.command/library-version.subcommand.js +47 -0
- package/dist/src/commands/dev.command/library-version.subcommand.js.map +1 -0
- package/dist/src/commands/dev.command/list-packages.subcommand.d.ts +7 -0
- package/dist/src/commands/dev.command/list-packages.subcommand.js +34 -0
- package/dist/src/commands/dev.command/list-packages.subcommand.js.map +1 -0
- package/dist/src/commands/dev.command/sync-publish.subcommand.d.ts +10 -0
- package/dist/src/commands/dev.command/sync-publish.subcommand.js +47 -0
- package/dist/src/commands/dev.command/sync-publish.subcommand.js.map +1 -0
- package/dist/src/commands/dev.command/update-bootstrap.subcommand.d.ts +10 -0
- package/dist/src/commands/dev.command/update-bootstrap.subcommand.js +47 -0
- package/dist/src/commands/dev.command/update-bootstrap.subcommand.js.map +1 -0
- package/dist/src/commands/dev.command.js +8 -0
- package/dist/src/commands/dev.command.js.map +1 -1
- package/dist/src/modules/developer/developer.service.d.ts +8 -0
- package/dist/src/modules/developer/developer.service.js +463 -0
- package/dist/src/modules/developer/developer.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -38,7 +38,396 @@ let DeveloperService = class DeveloperService {
|
|
|
38
38
|
console.log('\n', ...args);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
suppressWarnings() {
|
|
42
|
+
const originalEmitWarning = process.emitWarning;
|
|
43
|
+
process.emitWarning = () => { };
|
|
44
|
+
return () => {
|
|
45
|
+
process.emitWarning = originalEmitWarning;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async syncPublish(path, verbose = false) {
|
|
49
|
+
const restoreWarnings = this.suppressWarnings();
|
|
50
|
+
this.verbose = verbose;
|
|
51
|
+
path = await this.getRootPath(path);
|
|
52
|
+
const spinner = ora('Syncing and publishing libraries...').start();
|
|
53
|
+
const startTime = Date.now();
|
|
54
|
+
try {
|
|
55
|
+
const librariesPath = pathModule.join(path, 'libraries');
|
|
56
|
+
if (!(0, fs_1.existsSync)(librariesPath)) {
|
|
57
|
+
spinner.fail('Libraries directory not found.');
|
|
58
|
+
console.log(chalk.yellow('\nNo libraries directory found. Please create some libraries first.'));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
spinner.text = 'Scanning libraries...';
|
|
62
|
+
const libraries = [];
|
|
63
|
+
const libraryDirs = (0, fs_1.readdirSync)(librariesPath, { withFileTypes: true })
|
|
64
|
+
.filter((entry) => entry.isDirectory())
|
|
65
|
+
.map((entry) => pathModule.join(librariesPath, entry.name));
|
|
66
|
+
for (const libDir of libraryDirs) {
|
|
67
|
+
const packageJsonPath = pathModule.join(libDir, 'package.json');
|
|
68
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
69
|
+
this.log(chalk.yellow(`Skipping ${libDir} - no package.json found`));
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, 'utf8'));
|
|
73
|
+
if (!packageJson.name || !packageJson.version) {
|
|
74
|
+
this.log(chalk.yellow(`Skipping ${pathModule.basename(libDir)} - missing name or version in package.json`));
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
libraries.push({
|
|
78
|
+
path: packageJsonPath,
|
|
79
|
+
name: packageJson.name,
|
|
80
|
+
version: packageJson.version,
|
|
81
|
+
directory: libDir,
|
|
82
|
+
packageJsonPath,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (libraries.length === 0) {
|
|
86
|
+
spinner.fail('No valid libraries found.');
|
|
87
|
+
console.log(chalk.yellow('\nNo valid libraries found in the libraries directory.'));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
spinner.succeed(`Found ${libraries.length} libraries.`);
|
|
91
|
+
// Display found libraries
|
|
92
|
+
console.log(chalk.green.bold('\nš¦ Found Libraries:\n'));
|
|
93
|
+
for (const lib of libraries) {
|
|
94
|
+
console.log(` ${chalk.cyan(lib.name)} - ${chalk.gray(`v${lib.version}`)}`);
|
|
95
|
+
}
|
|
96
|
+
// Find highest version
|
|
97
|
+
spinner.start('Calculating new version...');
|
|
98
|
+
let highestVersion = libraries[0].version;
|
|
99
|
+
for (const lib of libraries) {
|
|
100
|
+
if (this.compareVersions(lib.version, highestVersion) > 0) {
|
|
101
|
+
highestVersion = lib.version;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const newVersion = this.incrementPatchVersion(highestVersion);
|
|
105
|
+
spinner.succeed(`Version calculated: ${chalk.gray(`v${highestVersion}`)} ā ${chalk.green(`v${newVersion}`)}`);
|
|
106
|
+
console.log(chalk.blue(`\nšÆ Current highest version: v${highestVersion}`));
|
|
107
|
+
console.log(chalk.green(`⨠New synchronized version: v${newVersion}\n`));
|
|
108
|
+
// Update all package.json files
|
|
109
|
+
spinner.start('Updating package.json files...');
|
|
110
|
+
for (const lib of libraries) {
|
|
111
|
+
const packageJson = JSON.parse(await (0, promises_1.readFile)(lib.packageJsonPath, 'utf8'));
|
|
112
|
+
packageJson.version = newVersion;
|
|
113
|
+
await (0, promises_1.writeFile)(lib.packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf8');
|
|
114
|
+
this.log(chalk.gray(` ā
${lib.name} updated to v${newVersion}`));
|
|
115
|
+
}
|
|
116
|
+
spinner.succeed(`All libraries synchronized to version ${chalk.green(`v${newVersion}`)}`);
|
|
117
|
+
// Build and publish all libraries
|
|
118
|
+
console.log(chalk.green.bold('\nšØ Building and Publishing Libraries:\n'));
|
|
119
|
+
let successCount = 0;
|
|
120
|
+
let failCount = 0;
|
|
121
|
+
const failedLibraries = [];
|
|
122
|
+
for (const lib of libraries) {
|
|
123
|
+
spinner.start(`Processing ${chalk.cyan(lib.name)}...`);
|
|
124
|
+
try {
|
|
125
|
+
// Install dependencies
|
|
126
|
+
spinner.text = `${chalk.cyan(lib.name)}: Installing dependencies...`;
|
|
127
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.PNPM, ['install'], { cwd: lib.directory }, true);
|
|
128
|
+
// Build
|
|
129
|
+
spinner.text = `${chalk.cyan(lib.name)}: Building...`;
|
|
130
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.PNPM, ['run', 'build'], { cwd: lib.directory }, true);
|
|
131
|
+
// Publish
|
|
132
|
+
spinner.text = `${chalk.cyan(lib.name)}: Publishing to npm...`;
|
|
133
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.PNPM, ['publish', '--access', 'public', '--no-git-checks'], { cwd: lib.directory }, true);
|
|
134
|
+
successCount++;
|
|
135
|
+
spinner.succeed(`${chalk.cyan(lib.name)} ${chalk.green('ā')} Built and published successfully`);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
failCount++;
|
|
139
|
+
failedLibraries.push(lib.name);
|
|
140
|
+
spinner.fail(`${chalk.cyan(lib.name)} ${chalk.red('ā')} Failed`);
|
|
141
|
+
this.log(chalk.red(`Error: ${error.message}`));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Summary
|
|
145
|
+
const endTime = Date.now();
|
|
146
|
+
const duration = ((endTime - startTime) / 1000).toFixed(2);
|
|
147
|
+
console.log(chalk.gray('\n' + 'ā'.repeat(60)));
|
|
148
|
+
console.log(chalk.green.bold('\nš Deployment Summary:\n'));
|
|
149
|
+
console.log(chalk.green(` ā
Successfully published: ${successCount}/${libraries.length}`));
|
|
150
|
+
if (failCount > 0) {
|
|
151
|
+
console.log(chalk.red(` ā Failed: ${failCount}/${libraries.length}`));
|
|
152
|
+
console.log(chalk.red('\n Failed libraries:'));
|
|
153
|
+
for (const name of failedLibraries) {
|
|
154
|
+
console.log(chalk.red(` ⢠${name}`));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
console.log(chalk.blue(` ā±ļø Total time: ${duration}s`));
|
|
158
|
+
console.log(chalk.gray('\n' + 'ā'.repeat(60) + '\n'));
|
|
159
|
+
if (failCount > 0) {
|
|
160
|
+
throw new Error(`${failCount} library(ies) failed to publish`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
spinner.fail('Failed to sync and publish libraries.');
|
|
165
|
+
console.error(chalk.red('Error syncing and publishing libraries:'), error);
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
restoreWarnings();
|
|
170
|
+
spinner.stop();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async showLibraryVersions(path, verbose = false) {
|
|
174
|
+
const restoreWarnings = this.suppressWarnings();
|
|
175
|
+
this.verbose = verbose;
|
|
176
|
+
path = await this.getRootPath(path);
|
|
177
|
+
const spinner = ora('Checking library versions...').start();
|
|
178
|
+
try {
|
|
179
|
+
const librariesPath = pathModule.join(path, 'libraries');
|
|
180
|
+
if (!(0, fs_1.existsSync)(librariesPath)) {
|
|
181
|
+
spinner.fail('Libraries directory not found.');
|
|
182
|
+
console.log(chalk.yellow('\nNo libraries directory found. Please create some libraries first.'));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
spinner.text = 'Scanning libraries...';
|
|
186
|
+
// Get all library directories
|
|
187
|
+
const libraryDirs = (0, fs_1.readdirSync)(librariesPath, { withFileTypes: true })
|
|
188
|
+
.filter((entry) => entry.isDirectory())
|
|
189
|
+
.map((entry) => pathModule.join(librariesPath, entry.name));
|
|
190
|
+
if (libraryDirs.length === 0) {
|
|
191
|
+
spinner.fail('No libraries found.');
|
|
192
|
+
console.log(chalk.yellow('\nNo libraries found in the libraries directory.'));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
spinner.succeed(`Found ${libraryDirs.length} libraries.`);
|
|
196
|
+
spinner.start('Checking package versions...');
|
|
197
|
+
const results = [];
|
|
198
|
+
for (const libDir of libraryDirs) {
|
|
199
|
+
const packageJsonPath = pathModule.join(libDir, 'package.json');
|
|
200
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
201
|
+
this.log(chalk.yellow(`Skipping ${libDir} - no package.json found`));
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const packageJson = JSON.parse(await (0, promises_1.readFile)(packageJsonPath, 'utf8'));
|
|
205
|
+
const libraryFolder = pathModule.basename(libDir);
|
|
206
|
+
const packageName = packageJson.name;
|
|
207
|
+
const currentVersion = packageJson.version;
|
|
208
|
+
if (!packageName || !currentVersion) {
|
|
209
|
+
this.log(chalk.yellow(`Skipping ${libraryFolder} - missing name or version in package.json`));
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
spinner.text = `Checking ${packageName}...`;
|
|
213
|
+
try {
|
|
214
|
+
// Get latest version from npm
|
|
215
|
+
const result = await this.runner.executeCommand(runner_service_1.ProgramName.NPM, ['view', packageName, 'version'], {}, true);
|
|
216
|
+
const latestVersion = result.stdout.trim();
|
|
217
|
+
const status = currentVersion === latestVersion ? 'ok' : 'outdated';
|
|
218
|
+
results.push({
|
|
219
|
+
libraryFolder,
|
|
220
|
+
packageName,
|
|
221
|
+
currentVersion,
|
|
222
|
+
latestVersion,
|
|
223
|
+
status,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
// Check if package is not published
|
|
228
|
+
if (error.message &&
|
|
229
|
+
(error.message.includes('404') ||
|
|
230
|
+
error.message.includes('E404') ||
|
|
231
|
+
error.message.includes('Not Found'))) {
|
|
232
|
+
results.push({
|
|
233
|
+
libraryFolder,
|
|
234
|
+
packageName,
|
|
235
|
+
currentVersion,
|
|
236
|
+
latestVersion: 'N/A',
|
|
237
|
+
status: 'unpublished',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
results.push({
|
|
242
|
+
libraryFolder,
|
|
243
|
+
packageName,
|
|
244
|
+
currentVersion,
|
|
245
|
+
latestVersion: 'N/A',
|
|
246
|
+
status: 'error',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
spinner.succeed('Version check completed.');
|
|
252
|
+
// Display results in a table
|
|
253
|
+
console.log(chalk.green.bold('\nš¦ Library Package Versions:\n'));
|
|
254
|
+
if (results.length === 0) {
|
|
255
|
+
console.log(chalk.yellow('No packages found in libraries.'));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
console.log(chalk.gray('ā'.repeat(100)));
|
|
259
|
+
// Table header
|
|
260
|
+
const folderHeader = 'Folder'.padEnd(20);
|
|
261
|
+
const nameHeader = 'Package Name'.padEnd(40);
|
|
262
|
+
const currentHeader = 'Current'.padEnd(15);
|
|
263
|
+
const latestHeader = 'Latest'.padEnd(15);
|
|
264
|
+
const statusHeader = 'Status';
|
|
265
|
+
console.log(chalk.white.bold(`${folderHeader} ${nameHeader} ${currentHeader} ${latestHeader} ${statusHeader}`));
|
|
266
|
+
console.log(chalk.gray('ā'.repeat(100)));
|
|
267
|
+
// Table rows
|
|
268
|
+
for (const pkg of results) {
|
|
269
|
+
const folder = pkg.libraryFolder.padEnd(20);
|
|
270
|
+
const name = pkg.packageName.padEnd(40);
|
|
271
|
+
const current = pkg.currentVersion.padEnd(15);
|
|
272
|
+
const latest = pkg.latestVersion.padEnd(15);
|
|
273
|
+
let statusText = '';
|
|
274
|
+
if (pkg.status === 'ok') {
|
|
275
|
+
statusText = chalk.green('ā Up to date');
|
|
276
|
+
}
|
|
277
|
+
else if (pkg.status === 'outdated') {
|
|
278
|
+
statusText = chalk.yellow('ā Update available');
|
|
279
|
+
}
|
|
280
|
+
else if (pkg.status === 'unpublished') {
|
|
281
|
+
statusText = chalk.blue('ā¹ Not published');
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
statusText = chalk.red('ā Error');
|
|
285
|
+
}
|
|
286
|
+
console.log(`${folder} ${name} ${current} ${latest} ${statusText}`);
|
|
287
|
+
}
|
|
288
|
+
// Summary
|
|
289
|
+
const outdatedCount = results.filter((r) => r.status === 'outdated').length;
|
|
290
|
+
const okCount = results.filter((r) => r.status === 'ok').length;
|
|
291
|
+
const unpublishedCount = results.filter((r) => r.status === 'unpublished').length;
|
|
292
|
+
const errorCount = results.filter((r) => r.status === 'error').length;
|
|
293
|
+
console.log(chalk.gray('\n' + 'ā'.repeat(100)));
|
|
294
|
+
console.log(chalk.white.bold('\nSummary:'));
|
|
295
|
+
console.log(chalk.green(` ā Up to date: ${okCount}`));
|
|
296
|
+
console.log(chalk.yellow(` ā Updates available: ${outdatedCount}`));
|
|
297
|
+
console.log(chalk.blue(` ā¹ Not published: ${unpublishedCount}`));
|
|
298
|
+
if (errorCount > 0) {
|
|
299
|
+
console.log(chalk.red(` ā Errors: ${errorCount}`));
|
|
300
|
+
}
|
|
301
|
+
console.log('');
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
spinner.fail('Failed to check library versions.');
|
|
305
|
+
console.error(chalk.red('Error checking library versions:'), error);
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
restoreWarnings();
|
|
310
|
+
spinner.stop();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async updateBootstrapFiles(path, verbose = false) {
|
|
314
|
+
const restoreWarnings = this.suppressWarnings();
|
|
315
|
+
this.verbose = verbose;
|
|
316
|
+
const spinner = ora('Updating bootstrap files...').start();
|
|
317
|
+
try {
|
|
318
|
+
path = await this.getRootPath(path);
|
|
319
|
+
const templatePath = pathModule.join(pathModule.dirname(path), 'template');
|
|
320
|
+
this.log(chalk.blue(`Source path: ${path}`));
|
|
321
|
+
this.log(chalk.blue(`Template path: ${templatePath}`));
|
|
322
|
+
// Clean template directory but keep .git
|
|
323
|
+
spinner.start('Cleaning template directory...');
|
|
324
|
+
if ((0, fs_1.existsSync)(templatePath)) {
|
|
325
|
+
const gitPath = pathModule.join(templatePath, '.git');
|
|
326
|
+
const hasGit = (0, fs_1.existsSync)(gitPath);
|
|
327
|
+
// Remove all items except .git directory
|
|
328
|
+
const entries = (0, fs_1.readdirSync)(templatePath, { withFileTypes: true });
|
|
329
|
+
for (const entry of entries) {
|
|
330
|
+
if (entry.name === '.git') {
|
|
331
|
+
this.log(chalk.gray('Skipping .git directory'));
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const fullPath = pathModule.join(templatePath, entry.name);
|
|
335
|
+
await this.fileSystem.remove(fullPath);
|
|
336
|
+
this.log(chalk.gray(`Removed: ${entry.name}`));
|
|
337
|
+
}
|
|
338
|
+
this.log(chalk.gray('Cleaned template directory (preserved .git)'));
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
await (0, promises_1.mkdir)(templatePath, { recursive: true });
|
|
342
|
+
this.log(chalk.blue('Template directory created.'));
|
|
343
|
+
}
|
|
344
|
+
spinner.succeed('Template directory cleaned.');
|
|
345
|
+
// Get all files tracked by git (respects .gitignore)
|
|
346
|
+
spinner.start('Getting list of files from repository...');
|
|
347
|
+
const result = await this.runner.executeCommand(runner_service_1.ProgramName.GIT, ['ls-files'], { cwd: path }, true);
|
|
348
|
+
const allFiles = result.stdout
|
|
349
|
+
.trim()
|
|
350
|
+
.split('\n')
|
|
351
|
+
.filter((f) => f.length > 0);
|
|
352
|
+
spinner.succeed(`Found ${allFiles.length} files in repository.`);
|
|
353
|
+
spinner.start('Filtering files...');
|
|
354
|
+
// Filter files from apps folder - only keep api and admin
|
|
355
|
+
const allowedAppsFolders = ['api', 'admin'];
|
|
356
|
+
const ignoredAppsFolders = new Set();
|
|
357
|
+
const files = allFiles.filter((file) => {
|
|
358
|
+
// Check if file is in apps directory
|
|
359
|
+
if (file.startsWith('apps/') || file.startsWith('apps\\')) {
|
|
360
|
+
const parts = file.split(/[/\\]/);
|
|
361
|
+
if (parts.length > 1) {
|
|
362
|
+
const appFolder = parts[1];
|
|
363
|
+
if (!allowedAppsFolders.includes(appFolder)) {
|
|
364
|
+
ignoredAppsFolders.add(appFolder);
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return true;
|
|
370
|
+
});
|
|
371
|
+
spinner.succeed('Files filtered.');
|
|
372
|
+
// Display ignored folders
|
|
373
|
+
if (ignoredAppsFolders.size > 0) {
|
|
374
|
+
spinner.info(chalk.blue(`Ignored apps folders: ${Array.from(ignoredAppsFolders).join(', ')}`));
|
|
375
|
+
spinner.start('Copying files...');
|
|
376
|
+
}
|
|
377
|
+
this.log(chalk.blue(`Found ${files.length} files to copy (${allFiles.length - files.length} files ignored)`));
|
|
378
|
+
// Copy each file maintaining directory structure
|
|
379
|
+
spinner.start('Copying files...');
|
|
380
|
+
let copiedCount = 0;
|
|
381
|
+
for (const file of files) {
|
|
382
|
+
const sourcePath = pathModule.join(path, file);
|
|
383
|
+
const destPath = pathModule.join(templatePath, file);
|
|
384
|
+
// Create directory if it doesn't exist
|
|
385
|
+
const destDir = pathModule.dirname(destPath);
|
|
386
|
+
if (!(0, fs_1.existsSync)(destDir)) {
|
|
387
|
+
await (0, promises_1.mkdir)(destDir, { recursive: true });
|
|
388
|
+
}
|
|
389
|
+
// Copy file
|
|
390
|
+
await this.fileSystem.copyFile(sourcePath, destPath);
|
|
391
|
+
copiedCount++;
|
|
392
|
+
if (verbose && copiedCount % 100 === 0) {
|
|
393
|
+
spinner.text = `Copying files... (${copiedCount}/${files.length})`;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// Commit and push changes to git
|
|
397
|
+
spinner.start('Committing changes to git...');
|
|
398
|
+
try {
|
|
399
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.GIT, ['add', '.'], { cwd: templatePath }, true);
|
|
400
|
+
// Check if there are changes to commit
|
|
401
|
+
const statusResult = await this.runner.executeCommand(runner_service_1.ProgramName.GIT, ['status', '--porcelain'], { cwd: templatePath }, true);
|
|
402
|
+
if (statusResult.stdout.trim().length > 0) {
|
|
403
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
404
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.GIT, ['commit', '-m', `Update-bootstrap-files-${timestamp}`], { cwd: templatePath }, true);
|
|
405
|
+
spinner.text = 'Pushing changes to remote repository...';
|
|
406
|
+
await this.runner.executeCommand(runner_service_1.ProgramName.GIT, ['push'], { cwd: templatePath }, true);
|
|
407
|
+
spinner.succeed(`Bootstrap files updated successfully. ${copiedCount} files copied and pushed to ${templatePath}`);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
spinner.succeed(`Bootstrap files updated successfully. ${copiedCount} files copied (no changes to commit)`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
catch (gitError) {
|
|
414
|
+
spinner.warn(`Bootstrap files copied (${copiedCount} files) but git operations failed. You may need to commit manually.`);
|
|
415
|
+
this.log(chalk.yellow('Git error:'), gitError.message);
|
|
416
|
+
}
|
|
417
|
+
this.log(chalk.green(`Successfully copied ${copiedCount} files to template directory.`));
|
|
418
|
+
}
|
|
419
|
+
catch (error) {
|
|
420
|
+
spinner.fail('Failed to update bootstrap files.');
|
|
421
|
+
console.error(chalk.red('Error updating bootstrap files:'), error);
|
|
422
|
+
throw error;
|
|
423
|
+
}
|
|
424
|
+
finally {
|
|
425
|
+
restoreWarnings();
|
|
426
|
+
spinner.stop();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
41
429
|
async route(path, verbose = false) {
|
|
430
|
+
const restoreWarnings = this.suppressWarnings();
|
|
42
431
|
this.verbose = verbose;
|
|
43
432
|
const spinner = ora('Analyzing NestJS routes...').start();
|
|
44
433
|
try {
|
|
@@ -94,6 +483,7 @@ let DeveloperService = class DeveloperService {
|
|
|
94
483
|
throw error;
|
|
95
484
|
}
|
|
96
485
|
finally {
|
|
486
|
+
restoreWarnings();
|
|
97
487
|
spinner.stop();
|
|
98
488
|
}
|
|
99
489
|
}
|
|
@@ -214,6 +604,32 @@ let DeveloperService = class DeveloperService {
|
|
|
214
604
|
};
|
|
215
605
|
return colors[method] || chalk.white;
|
|
216
606
|
}
|
|
607
|
+
parseVersion(version) {
|
|
608
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
609
|
+
if (!match) {
|
|
610
|
+
throw new Error(`Invalid version format: ${version}`);
|
|
611
|
+
}
|
|
612
|
+
return {
|
|
613
|
+
major: parseInt(match[1], 10),
|
|
614
|
+
minor: parseInt(match[2], 10),
|
|
615
|
+
patch: parseInt(match[3], 10),
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
compareVersions(v1, v2) {
|
|
619
|
+
const parsed1 = this.parseVersion(v1);
|
|
620
|
+
const parsed2 = this.parseVersion(v2);
|
|
621
|
+
if (parsed1.major !== parsed2.major) {
|
|
622
|
+
return parsed1.major - parsed2.major;
|
|
623
|
+
}
|
|
624
|
+
if (parsed1.minor !== parsed2.minor) {
|
|
625
|
+
return parsed1.minor - parsed2.minor;
|
|
626
|
+
}
|
|
627
|
+
return parsed1.patch - parsed2.patch;
|
|
628
|
+
}
|
|
629
|
+
incrementPatchVersion(version) {
|
|
630
|
+
const parsed = this.parseVersion(version);
|
|
631
|
+
return `${parsed.major}.${parsed.minor}.${parsed.patch + 1}`;
|
|
632
|
+
}
|
|
217
633
|
async createLibrary(path, libraryName, force = false, verbose = false, skipInstall = false) {
|
|
218
634
|
this.verbose = verbose;
|
|
219
635
|
this.log(chalk.blue('Starting library creation...'));
|
|
@@ -388,6 +804,7 @@ let DeveloperService = class DeveloperService {
|
|
|
388
804
|
.replace(/-/g, '_');
|
|
389
805
|
}
|
|
390
806
|
async resetDevelopmentEnvironment(cwd, verbose = false) {
|
|
807
|
+
const restoreWarnings = this.suppressWarnings();
|
|
391
808
|
this.verbose = verbose;
|
|
392
809
|
const spinner = ora('Resetting development environment...').start();
|
|
393
810
|
try {
|
|
@@ -404,6 +821,7 @@ let DeveloperService = class DeveloperService {
|
|
|
404
821
|
throw error;
|
|
405
822
|
}
|
|
406
823
|
finally {
|
|
824
|
+
restoreWarnings();
|
|
407
825
|
spinner.stop();
|
|
408
826
|
}
|
|
409
827
|
}
|
|
@@ -553,6 +971,7 @@ let DeveloperService = class DeveloperService {
|
|
|
553
971
|
}
|
|
554
972
|
}
|
|
555
973
|
async backupDatabase(cwd, verbose = false) {
|
|
974
|
+
const restoreWarnings = this.suppressWarnings();
|
|
556
975
|
this.verbose = verbose;
|
|
557
976
|
this.log('Backing up database...');
|
|
558
977
|
const spinner = ora('Backing up database...').start();
|
|
@@ -624,10 +1043,12 @@ let DeveloperService = class DeveloperService {
|
|
|
624
1043
|
throw error;
|
|
625
1044
|
}
|
|
626
1045
|
finally {
|
|
1046
|
+
restoreWarnings();
|
|
627
1047
|
spinner.stop();
|
|
628
1048
|
}
|
|
629
1049
|
}
|
|
630
1050
|
async initDatabase(cwd, verbose = false) {
|
|
1051
|
+
const restoreWarnings = this.suppressWarnings();
|
|
631
1052
|
this.verbose = verbose;
|
|
632
1053
|
this.log('Initializing database...');
|
|
633
1054
|
const spinner = ora('Initializing database...').start();
|
|
@@ -687,10 +1108,12 @@ let DeveloperService = class DeveloperService {
|
|
|
687
1108
|
throw error;
|
|
688
1109
|
}
|
|
689
1110
|
finally {
|
|
1111
|
+
restoreWarnings();
|
|
690
1112
|
spinner.stop();
|
|
691
1113
|
}
|
|
692
1114
|
}
|
|
693
1115
|
async restoreDatabase(cwd, verbose = false) {
|
|
1116
|
+
const restoreWarnings = this.suppressWarnings();
|
|
694
1117
|
this.verbose = verbose;
|
|
695
1118
|
this.log('Restoring database from backup...');
|
|
696
1119
|
const spinner = ora('Restoring database from backup...').start();
|
|
@@ -886,9 +1309,49 @@ let DeveloperService = class DeveloperService {
|
|
|
886
1309
|
throw error;
|
|
887
1310
|
}
|
|
888
1311
|
finally {
|
|
1312
|
+
restoreWarnings();
|
|
889
1313
|
spinner.stop();
|
|
890
1314
|
}
|
|
891
1315
|
}
|
|
1316
|
+
async listHedHogPackages() {
|
|
1317
|
+
const restoreWarnings = this.suppressWarnings();
|
|
1318
|
+
const spinner = ora('Fetching @hed-hog packages...').start();
|
|
1319
|
+
try {
|
|
1320
|
+
// Fetch packages from npm registry
|
|
1321
|
+
const response = await fetch('https://registry.npmjs.org/-/v1/search?text=scope:hed-hog&size=250');
|
|
1322
|
+
if (!response.ok) {
|
|
1323
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1324
|
+
}
|
|
1325
|
+
const data = await response.json();
|
|
1326
|
+
const packages = data.objects;
|
|
1327
|
+
spinner.succeed(chalk.green(`Found ${packages.length} package(s) in @hed-hog:`));
|
|
1328
|
+
if (packages.length === 0) {
|
|
1329
|
+
console.log(chalk.yellow('\nNo packages found.'));
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
console.log('');
|
|
1333
|
+
// Sort packages alphabetically by name
|
|
1334
|
+
packages.sort((a, b) => a.package.name.localeCompare(b.package.name));
|
|
1335
|
+
// Display packages in a formatted table
|
|
1336
|
+
packages.forEach((pkg) => {
|
|
1337
|
+
const name = chalk.cyan(pkg.package.name);
|
|
1338
|
+
const version = chalk.gray(`v${pkg.package.version}`);
|
|
1339
|
+
const description = pkg.package.description || chalk.gray('No description');
|
|
1340
|
+
console.log(`${name} ${version}`);
|
|
1341
|
+
console.log(` ${description}`);
|
|
1342
|
+
console.log('');
|
|
1343
|
+
});
|
|
1344
|
+
console.log(chalk.gray(`Total: ${packages.length} package(s)`));
|
|
1345
|
+
}
|
|
1346
|
+
catch (error) {
|
|
1347
|
+
spinner.fail('Failed to fetch packages.');
|
|
1348
|
+
console.error(chalk.red('Error:'), error.message);
|
|
1349
|
+
throw error;
|
|
1350
|
+
}
|
|
1351
|
+
finally {
|
|
1352
|
+
restoreWarnings();
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
892
1355
|
};
|
|
893
1356
|
exports.DeveloperService = DeveloperService;
|
|
894
1357
|
exports.DeveloperService = DeveloperService = __decorate([
|