purgetss 7.1.0 → 7.1.2
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 +3 -3
- package/bin/purgetss +75 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ With **PurgeTSS**, creating visually appealing and dynamic mobile apps becomes m
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
## What's New in v7.1.
|
|
21
|
+
## What's New in v7.1.x
|
|
22
22
|
|
|
23
23
|
**Major Refactoring & ESM Migration**: PurgeTSS v7.1 has been completely refactored with improved code organization, better ESM compatibility, enhanced error handling, and a more intuitive CLI experience.
|
|
24
24
|
|
|
@@ -59,7 +59,7 @@ With **PurgeTSS**, creating visually appealing and dynamic mobile apps becomes m
|
|
|
59
59
|
|
|
60
60
|
For most users, upgrading is seamless:
|
|
61
61
|
```bash
|
|
62
|
-
npm install -g purgetss@
|
|
62
|
+
npm install -g purgetss@latest
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
**Key changes to note:**
|
|
@@ -94,7 +94,7 @@ Overall, *PurgeTSS* aims to simplify the mobile app development process, offerin
|
|
|
94
94
|
|
|
95
95
|
## Table of Content
|
|
96
96
|
|
|
97
|
-
- [What's New in v7.1](
|
|
97
|
+
- [What's New in v7.1](https://purgetss.com/#whats-new-in-v71x)
|
|
98
98
|
- [Installation](https://purgetss.com/docs/installation)
|
|
99
99
|
- [Commands](https://purgetss.com/docs/commands)
|
|
100
100
|
- Customization
|
package/bin/purgetss
CHANGED
|
@@ -418,6 +418,58 @@ program
|
|
|
418
418
|
})
|
|
419
419
|
})
|
|
420
420
|
|
|
421
|
+
// Function to calculate string similarity (Levenshtein distance)
|
|
422
|
+
function calculateSimilarity(str1, str2) {
|
|
423
|
+
const matrix = []
|
|
424
|
+
|
|
425
|
+
// Create distance matrix
|
|
426
|
+
for (let i = 0; i <= str2.length; i++) {
|
|
427
|
+
matrix[i] = [i]
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
for (let j = 0; j <= str1.length; j++) {
|
|
431
|
+
matrix[0][j] = j
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Fill the matrix
|
|
435
|
+
for (let i = 1; i <= str2.length; i++) {
|
|
436
|
+
for (let j = 1; j <= str1.length; j++) {
|
|
437
|
+
if (str2.charAt(i - 1) === str1.charAt(j - 1)) {
|
|
438
|
+
matrix[i][j] = matrix[i - 1][j - 1]
|
|
439
|
+
} else {
|
|
440
|
+
matrix[i][j] = Math.min(
|
|
441
|
+
matrix[i - 1][j - 1] + 1, // substitution
|
|
442
|
+
matrix[i][j - 1] + 1, // insertion
|
|
443
|
+
matrix[i - 1][j] + 1 // deletion
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return matrix[str2.length][str1.length]
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Function to find similar commands
|
|
453
|
+
function findSimilarCommands(input, validCommands) {
|
|
454
|
+
const suggestions = []
|
|
455
|
+
|
|
456
|
+
validCommands.forEach(cmd => {
|
|
457
|
+
const distance = calculateSimilarity(input.toLowerCase(), cmd.toLowerCase())
|
|
458
|
+
const similarity = 1 - (distance / Math.max(input.length, cmd.length))
|
|
459
|
+
|
|
460
|
+
// Suggest commands with similarity > 0.4 or that start with the same letter
|
|
461
|
+
if (similarity > 0.4 || cmd.toLowerCase().startsWith(input.toLowerCase().charAt(0))) {
|
|
462
|
+
suggestions.push({ command: cmd, similarity })
|
|
463
|
+
}
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
// Sort by similarity and return top 3
|
|
467
|
+
return suggestions
|
|
468
|
+
.sort((a, b) => b.similarity - a.similarity)
|
|
469
|
+
.slice(0, 3)
|
|
470
|
+
.map(s => s.command)
|
|
471
|
+
}
|
|
472
|
+
|
|
421
473
|
// Validate arguments before parsing
|
|
422
474
|
const args = process.argv.slice(2)
|
|
423
475
|
if (args.length > 0) {
|
|
@@ -436,7 +488,29 @@ if (args.length > 0) {
|
|
|
436
488
|
// Check if it's an unknown command (doesn't start with - and not in valid commands)
|
|
437
489
|
if (!firstArg.startsWith('-') && !validCommands.includes(firstArg)) {
|
|
438
490
|
console.log(chalk.red(`\nUnknown command: ${firstArg}`))
|
|
439
|
-
|
|
491
|
+
|
|
492
|
+
// Find similar commands and suggest them
|
|
493
|
+
const suggestions = findSimilarCommands(firstArg, validCommands)
|
|
494
|
+
if (suggestions.length > 0) {
|
|
495
|
+
console.log(chalk.yellow('Did you mean one of these?'))
|
|
496
|
+
suggestions.forEach(suggestion => {
|
|
497
|
+
// Get the command info to show alias if available
|
|
498
|
+
const commandInfo = program.commands.find(cmd =>
|
|
499
|
+
cmd.name() === suggestion || cmd.alias() === suggestion
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
if (commandInfo) {
|
|
503
|
+
const displayName = commandInfo.alias()
|
|
504
|
+
? `${commandInfo.name()}|${commandInfo.alias()}`
|
|
505
|
+
: commandInfo.name()
|
|
506
|
+
console.log(` ${chalk.cyan(displayName)}`)
|
|
507
|
+
} else {
|
|
508
|
+
console.log(` ${chalk.cyan(suggestion)}`)
|
|
509
|
+
}
|
|
510
|
+
})
|
|
511
|
+
} else {
|
|
512
|
+
console.log(chalk.yellow('\nFor help, run: purgetss -h'))
|
|
513
|
+
}
|
|
440
514
|
process.exit(1)
|
|
441
515
|
}
|
|
442
516
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "purgetss",
|
|
4
|
-
"version": "7.1.
|
|
4
|
+
"version": "7.1.2",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"purgetss": "bin/purgetss"
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"homepage": "https://github.com/macCesar/purgeTSS#readme",
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@fortawesome/fontawesome-free": "^6.7.2",
|
|
69
|
-
"caporal": "^1.4.0",
|
|
70
69
|
"chalk": "^5.4.1",
|
|
71
70
|
"chroma-js": "^3.1.2",
|
|
72
71
|
"command-exists": "^1.2.9",
|