draftify-cli 1.0.12 → 1.0.13
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/index.js +18 -1
- package/dist/repl.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -44,8 +44,25 @@ async function checkVersion() {
|
|
|
44
44
|
try {
|
|
45
45
|
const latestVersion = JSON.parse(data).version;
|
|
46
46
|
const currentVersion = require("../package.json").version;
|
|
47
|
-
// Semver comparison:
|
|
47
|
+
// Semver comparison: we only want to block older versions
|
|
48
|
+
let isOlder = false;
|
|
48
49
|
if (latestVersion && currentVersion && latestVersion !== currentVersion) {
|
|
50
|
+
// Simple numeric split comparison for semver
|
|
51
|
+
const latestParts = latestVersion.split('.').map(Number);
|
|
52
|
+
const currentParts = currentVersion.split('.').map(Number);
|
|
53
|
+
for (let i = 0; i < Math.max(latestParts.length, currentParts.length); i++) {
|
|
54
|
+
const l = latestParts[i] || 0;
|
|
55
|
+
const c = currentParts[i] || 0;
|
|
56
|
+
if (l > c) {
|
|
57
|
+
isOlder = true;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (l < c) {
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (isOlder) {
|
|
49
66
|
console.error(`\n\x1b[31m[!] Elavult verziót használsz: ${currentVersion}\x1b[0m`);
|
|
50
67
|
console.error(`\x1b[33mKérlek frissítsd a legújabbra (${latestVersion}) a folytatáshoz:\x1b[0m`);
|
|
51
68
|
console.error(`\n \x1b[36mnpm install -g draftify-cli@latest\x1b[0m\n`);
|
package/dist/repl.js
CHANGED
|
@@ -662,22 +662,22 @@ async function startRepl(initialUsername) {
|
|
|
662
662
|
search = search.replace(/\r\n/g, '\n');
|
|
663
663
|
replace = replace.replace(/\r\n/g, '\n');
|
|
664
664
|
if (normalizedFile.includes(search)) {
|
|
665
|
-
fileContent = normalizedFile.replace(search, replace);
|
|
665
|
+
fileContent = normalizedFile.replace(search, () => replace);
|
|
666
666
|
diffApplied = true;
|
|
667
667
|
}
|
|
668
668
|
else {
|
|
669
669
|
// Fallback 1: try stripping leading/trailing empty lines/whitespace from the search block
|
|
670
670
|
const trimmedSearch = search.trim();
|
|
671
671
|
if (trimmedSearch && normalizedFile.includes(trimmedSearch)) {
|
|
672
|
-
fileContent = normalizedFile.replace(trimmedSearch, replace.trim());
|
|
672
|
+
fileContent = normalizedFile.replace(trimmedSearch, () => replace.trim());
|
|
673
673
|
diffApplied = true;
|
|
674
674
|
}
|
|
675
675
|
else {
|
|
676
676
|
// Fallback 2: Regex fuzzy matching that ignores exact whitespace differences (e.g. indentation or newlines)
|
|
677
|
-
const escapedSearch = trimmedSearch.replace(/[.*+?^${}()|[\\]
|
|
677
|
+
const escapedSearch = trimmedSearch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace(/\s+/g, '\\s+');
|
|
678
678
|
const regex = new RegExp(escapedSearch);
|
|
679
679
|
if (regex.test(normalizedFile)) {
|
|
680
|
-
fileContent = normalizedFile.replace(regex, replace.trim());
|
|
680
|
+
fileContent = normalizedFile.replace(regex, () => replace.trim());
|
|
681
681
|
diffApplied = true;
|
|
682
682
|
}
|
|
683
683
|
else {
|