obsidian-plugin-config 1.1.3 → 1.1.4
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/package.json
CHANGED
|
@@ -93,7 +93,23 @@ async function updateEnvFile(envKey: string, vaultPath: string): Promise<void> {
|
|
|
93
93
|
console.log(`✅ Updated ${envKey} in .env file`);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function validateVaultPath(vaultPath: string): boolean {
|
|
97
|
+
// Check if the path contains .obsidian directory
|
|
98
|
+
const obsidianPath = path.join(vaultPath, ".obsidian");
|
|
99
|
+
const pluginsPath = path.join(vaultPath, ".obsidian", "plugins");
|
|
100
|
+
|
|
101
|
+
return fs.existsSync(obsidianPath) && fs.existsSync(pluginsPath);
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
function getVaultPath(vaultPath: string): string {
|
|
105
|
+
// Validate that this is a proper vault path
|
|
106
|
+
if (!validateVaultPath(vaultPath)) {
|
|
107
|
+
console.error(`❌ Invalid vault path: ${vaultPath}`);
|
|
108
|
+
console.error(` The path must contain a .obsidian/plugins directory`);
|
|
109
|
+
console.error(` Please enter a valid Obsidian vault path`);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
|
|
97
113
|
// Check if the path already contains the plugins directory path
|
|
98
114
|
const pluginsPath = path.join(".obsidian", "plugins");
|
|
99
115
|
if (vaultPath.includes(pluginsPath)) {
|
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import { readFile, writeFile } from "fs/promises";
|
|
2
2
|
import dedent from "dedent";
|
|
3
|
-
import { inc, valid } from "semver";
|
|
4
3
|
import { askQuestion, createReadlineInterface, gitExec, ensureGitSync } from "./utils.js";
|
|
5
4
|
|
|
5
|
+
// Simple version increment functions to avoid semver compatibility issues
|
|
6
|
+
function incrementVersion(version: string, type: 'patch' | 'minor' | 'major'): string {
|
|
7
|
+
const parts = version.split('.').map(Number);
|
|
8
|
+
if (parts.length !== 3) return '';
|
|
9
|
+
|
|
10
|
+
switch (type) {
|
|
11
|
+
case 'patch':
|
|
12
|
+
parts[2]++;
|
|
13
|
+
break;
|
|
14
|
+
case 'minor':
|
|
15
|
+
parts[1]++;
|
|
16
|
+
parts[2] = 0;
|
|
17
|
+
break;
|
|
18
|
+
case 'major':
|
|
19
|
+
parts[0]++;
|
|
20
|
+
parts[1] = 0;
|
|
21
|
+
parts[2] = 0;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return parts.join('.');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function isValidVersion(version: string): boolean {
|
|
29
|
+
const versionRegex = /^\d+\.\d+\.\d+$/;
|
|
30
|
+
return versionRegex.test(version);
|
|
31
|
+
}
|
|
32
|
+
|
|
6
33
|
const rl = createReadlineInterface();
|
|
7
34
|
|
|
8
35
|
async function getTargetVersion(currentVersion: string): Promise<string> {
|
|
@@ -18,15 +45,16 @@ async function getTargetVersion(currentVersion: string): Promise<string> {
|
|
|
18
45
|
switch (updateType.trim()) {
|
|
19
46
|
case "p":
|
|
20
47
|
case "1":
|
|
21
|
-
return
|
|
48
|
+
return incrementVersion(currentVersion, "patch");
|
|
22
49
|
case "min":
|
|
23
50
|
case "2":
|
|
24
|
-
return
|
|
51
|
+
return incrementVersion(currentVersion, "minor");
|
|
25
52
|
case "maj":
|
|
26
53
|
case "3":
|
|
27
|
-
return
|
|
54
|
+
return incrementVersion(currentVersion, "major");
|
|
28
55
|
default:
|
|
29
|
-
|
|
56
|
+
const trimmed = updateType.trim();
|
|
57
|
+
return isValidVersion(trimmed) ? trimmed : "";
|
|
30
58
|
}
|
|
31
59
|
}
|
|
32
60
|
|