obsidian-plugin-config 1.1.4 → 1.1.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.
- package/README.md +70 -90
- package/package.json +11 -12
- package/scripts/inject-path.ts +12 -113
- package/scripts/inject-prompt.ts +4 -4
- package/src/main.ts +106 -0
- package/src/utils/SettingsHelper.ts +1 -1
- package/versions.json +2 -1
- package/src/test-centralized-utils.ts +0 -23
package/README.md
CHANGED
|
@@ -1,117 +1,97 @@
|
|
|
1
1
|
# Obsidian Plugin Config
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
🎯 Système d'injection pour plugins Obsidian autonomes.
|
|
3
|
+
🎯 Injection system for standalone Obsidian plugins.
|
|
6
4
|
|
|
7
5
|
[](https://www.npmjs.com/package/obsidian-plugin-config)
|
|
8
6
|
[](LICENSE)
|
|
9
7
|
|
|
10
|
-
**
|
|
8
|
+
**Current version: 1.1.5**
|
|
11
9
|
|
|
12
|
-
## Installation
|
|
10
|
+
## Installation
|
|
13
11
|
|
|
14
12
|
```bash
|
|
15
13
|
npm install -g obsidian-plugin-config
|
|
16
14
|
```
|
|
17
15
|
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
### Injection dans le répertoire courant
|
|
16
|
+
## Update
|
|
21
17
|
|
|
22
18
|
```bash
|
|
23
|
-
|
|
24
|
-
obsidian-inject
|
|
19
|
+
npm update -g obsidian-plugin-config
|
|
25
20
|
```
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
obsidian-inject ../mon-plugin
|
|
31
|
-
obsidian-inject "C:\chemin\vers\plugin"
|
|
32
|
-
```
|
|
22
|
+
## Commands
|
|
33
23
|
|
|
34
|
-
###
|
|
24
|
+
### For Plugin Config Development
|
|
35
25
|
|
|
36
26
|
```bash
|
|
37
|
-
#
|
|
38
|
-
yarn
|
|
39
|
-
yarn
|
|
27
|
+
# Development
|
|
28
|
+
yarn start # Install dependencies + update exports
|
|
29
|
+
yarn build # Build the project
|
|
30
|
+
yarn dev # Development build
|
|
31
|
+
yarn real # Build to real vault
|
|
32
|
+
|
|
33
|
+
# Git Operations
|
|
34
|
+
yarn acp # Add, commit, push
|
|
35
|
+
yarn bacp # Build + add, commit, push
|
|
36
|
+
yarn v # Update version
|
|
37
|
+
|
|
38
|
+
# NPM Publishing
|
|
39
|
+
yarn build-npm # Build NPM package
|
|
40
|
+
yarn publish-npm # Publish to NPM
|
|
41
|
+
|
|
42
|
+
# Help
|
|
43
|
+
yarn help # Show help
|
|
40
44
|
```
|
|
41
45
|
|
|
42
|
-
###
|
|
46
|
+
### For Plugin Injection
|
|
43
47
|
|
|
44
48
|
```bash
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
- ✅ **Scripts locaux autonomes** : `esbuild.config.ts`, `acp.ts`, `update-version.ts`, `utils.ts`, `help.ts`, `release.ts`
|
|
51
|
-
- ✅ **Configuration package.json** : scripts, dépendances, protection yarn obligatoire, `"type": "module"` pour ESM
|
|
52
|
-
- ✅ **Template tsconfig.json** : configuration TypeScript moderne optimisée
|
|
53
|
-
- ✅ **Installation automatique** des dépendances avec yarn
|
|
54
|
-
- ✅ **Analyse des imports centralisés** avec avertissements
|
|
55
|
-
- ✅ **Fichier de traçabilité** : `.injection-info.json` (version, date d'injection)
|
|
56
|
-
|
|
57
|
-
## 📋 Suivi des versions d'injection
|
|
58
|
-
|
|
59
|
-
Le système crée un fichier `.injection-info.json` dans chaque plugin injecté pour tracer :
|
|
60
|
-
|
|
61
|
-
- **Version de l'injecteur** utilisée
|
|
62
|
-
- **Date d'injection**
|
|
63
|
-
- **Nom de l'injecteur** (`obsidian-plugin-config`)
|
|
64
|
-
|
|
65
|
-
> ⚠️ **Important** : Le fichier `.injection-info.json` est **commité avec le plugin** pour assurer la traçabilité sur GitHub et permettre de voir facilement qu'un plugin a été injecté et avec quelle version.
|
|
66
|
-
|
|
67
|
-
### Statuts possibles lors de la vérification
|
|
68
|
-
|
|
69
|
-
- ✅ **Plugin injecté** : Affiche version, date et détecte les mises à jour disponibles
|
|
70
|
-
- ⚠️ **Plugin injecté (legacy)** : Injecté avec l'ancien système, re-injection recommandée
|
|
71
|
-
- ❌ **Plugin non injecté** : Aucune injection détectée
|
|
72
|
-
|
|
73
|
-
## ⚠️ Configuration ESM Moderne
|
|
74
|
-
|
|
75
|
-
Le système utilise une configuration TypeScript moderne avec ESM. Si votre plugin a des imports relatifs, vous devrez peut-être les corriger :
|
|
49
|
+
# Interactive injection (recommended)
|
|
50
|
+
obsidian-inject
|
|
51
|
+
obsidian-inject ../my-plugin
|
|
52
|
+
yarn inject-prompt "../my-plugin"
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
54
|
+
# Automatic injection
|
|
55
|
+
obsidian-inject ../my-plugin --yes
|
|
56
|
+
yarn inject-path ../my-plugin --yes
|
|
80
57
|
|
|
81
|
-
|
|
82
|
-
|
|
58
|
+
# Verification only
|
|
59
|
+
yarn check-plugin ../my-plugin
|
|
83
60
|
```
|
|
84
61
|
|
|
85
|
-
|
|
62
|
+
## What is injected
|
|
63
|
+
|
|
64
|
+
- ✅ **Standalone local scripts**: `esbuild.config.ts`, `acp.ts`, `update-version.ts`, etc.
|
|
65
|
+
- ✅ **package.json configuration**: scripts, dependencies, yarn protection
|
|
66
|
+
- ✅ **tsconfig.json template**: modern optimized TypeScript configuration
|
|
67
|
+
- ✅ **Automatic installation** of dependencies with yarn
|
|
68
|
+
- ✅ **Traceability file**: `.injection-info.json` (version, injection date)
|
|
86
69
|
|
|
87
|
-
##
|
|
70
|
+
## Commands available after injection
|
|
88
71
|
|
|
89
72
|
```bash
|
|
90
|
-
yarn build #
|
|
91
|
-
yarn dev #
|
|
92
|
-
yarn start #
|
|
93
|
-
yarn real # Build
|
|
73
|
+
yarn build # Production build
|
|
74
|
+
yarn dev # Development build + watch
|
|
75
|
+
yarn start # Install dependencies + start dev
|
|
76
|
+
yarn real # Build to real vault
|
|
94
77
|
yarn acp # Add-commit-push
|
|
95
78
|
yarn bacp # Build + add-commit-push
|
|
96
|
-
yarn
|
|
97
|
-
yarn
|
|
98
|
-
yarn
|
|
99
|
-
yarn r # Alias pour release
|
|
100
|
-
yarn help # Aide complète
|
|
101
|
-
yarn h # Alias pour help
|
|
79
|
+
yarn v # Update version
|
|
80
|
+
yarn release # GitHub release
|
|
81
|
+
yarn help # Full help
|
|
102
82
|
```
|
|
103
83
|
|
|
104
84
|
## Architecture
|
|
105
85
|
|
|
106
|
-
|
|
86
|
+
The plugin becomes **100% STANDALONE** after injection:
|
|
107
87
|
|
|
108
|
-
- ❌ **
|
|
109
|
-
- ✅ **Scripts
|
|
110
|
-
- ✅ **
|
|
111
|
-
- ✅ **
|
|
112
|
-
- ✅ **Compatible
|
|
88
|
+
- ❌ **No external dependencies** required
|
|
89
|
+
- ✅ **Scripts integrated locally**
|
|
90
|
+
- ✅ **Updatable** via re-injection
|
|
91
|
+
- ✅ **Yarn protection** maintained
|
|
92
|
+
- ✅ **Compatible with all Obsidian plugins**
|
|
113
93
|
|
|
114
|
-
##
|
|
94
|
+
## Local Development (for contributors)
|
|
115
95
|
|
|
116
96
|
### Installation
|
|
117
97
|
|
|
@@ -121,37 +101,37 @@ cd obsidian-plugin-config
|
|
|
121
101
|
yarn install
|
|
122
102
|
```
|
|
123
103
|
|
|
124
|
-
###
|
|
104
|
+
### Local injection test
|
|
125
105
|
|
|
126
106
|
```bash
|
|
127
|
-
#
|
|
128
|
-
yarn inject ../
|
|
107
|
+
# Automatic injection
|
|
108
|
+
yarn inject ../my-plugin --yes
|
|
129
109
|
|
|
130
|
-
# Injection
|
|
131
|
-
yarn inject-prompt "../
|
|
110
|
+
# Injection with prompts
|
|
111
|
+
yarn inject-prompt "../my-plugin"
|
|
132
112
|
```
|
|
133
113
|
|
|
134
|
-
###
|
|
114
|
+
### Full workflow: Local → NPM
|
|
135
115
|
|
|
136
116
|
```bash
|
|
137
|
-
# 1.
|
|
117
|
+
# 1. Local development
|
|
138
118
|
yarn inject ../test-plugin --yes
|
|
139
119
|
|
|
140
|
-
# 2.
|
|
141
|
-
#
|
|
120
|
+
# 2. Fix ESM imports if necessary
|
|
121
|
+
# Example: "./utils.ts" → "./utils.js"
|
|
142
122
|
|
|
143
|
-
# 3. Build
|
|
123
|
+
# 3. Build and publish to NPM
|
|
144
124
|
yarn build-npm
|
|
145
125
|
yarn update-version
|
|
146
126
|
npm login
|
|
147
127
|
npm publish
|
|
148
128
|
```
|
|
149
129
|
|
|
150
|
-
###
|
|
130
|
+
### Maintenance commands
|
|
151
131
|
|
|
152
132
|
```bash
|
|
153
133
|
yarn acp # Add, commit, push
|
|
154
|
-
yarn update-version #
|
|
155
|
-
yarn build-npm # Build package
|
|
156
|
-
yarn help #
|
|
134
|
+
yarn update-version # Update version
|
|
135
|
+
yarn build-npm # Build NPM package
|
|
136
|
+
yarn help # Full help
|
|
157
137
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obsidian-plugin-config",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Système d'injection pour plugins Obsidian autonomes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -20,26 +20,25 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"start": "yarn install && yarn run update-exports",
|
|
23
|
+
"i": "yarn install && yarn run update-exports",
|
|
23
24
|
"update-exports": "node scripts/update-exports.js",
|
|
25
|
+
"ue": "node scripts/update-exports.js",
|
|
24
26
|
"acp": "tsx scripts/acp.ts",
|
|
27
|
+
"bacp": "tsx scripts/acp.ts -b",
|
|
25
28
|
"update-version": "tsx scripts/update-version-config.ts",
|
|
26
29
|
"v": "tsx scripts/update-version-config.ts",
|
|
30
|
+
"build": "tsc -noEmit -skipLibCheck",
|
|
31
|
+
"dev": "tsx scripts/esbuild.config.ts",
|
|
32
|
+
"real": "tsx scripts/esbuild.config.ts production real",
|
|
33
|
+
"lint": "eslint . --ext .ts",
|
|
34
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
27
35
|
"inject-path": "tsx scripts/inject-path.ts",
|
|
28
|
-
"inject": "tsx scripts/inject-path.ts",
|
|
29
36
|
"inject-prompt": "tsx scripts/inject-prompt.ts",
|
|
30
37
|
"check-plugin": "tsx scripts/inject-path.ts --dry-run",
|
|
31
38
|
"build-npm": "tsx scripts/build-npm.ts",
|
|
32
39
|
"publish-npm": "tsx scripts/build-npm.ts",
|
|
33
40
|
"help": "tsx scripts/help.ts",
|
|
34
|
-
"h": "tsx scripts/help.ts"
|
|
35
|
-
"lint": "eslint . --ext .ts",
|
|
36
|
-
"lint:fix": "eslint . --ext .ts --fix",
|
|
37
|
-
"dev": "tsx scripts/esbuild.config.ts",
|
|
38
|
-
"build": "tsc -noEmit -skipLibCheck",
|
|
39
|
-
"real": "tsx scripts/esbuild.config.ts production real",
|
|
40
|
-
"bacp": "tsx scripts/acp.ts -b",
|
|
41
|
-
"release": "tsx scripts/release.ts",
|
|
42
|
-
"r": "tsx scripts/release.ts"
|
|
41
|
+
"h": "tsx scripts/help.ts"
|
|
43
42
|
},
|
|
44
43
|
"exports": {
|
|
45
44
|
".": "./src/index.ts",
|
|
@@ -94,4 +93,4 @@
|
|
|
94
93
|
"url": "https://github.com/3C0D/obsidian-plugin-config.git"
|
|
95
94
|
},
|
|
96
95
|
"author": "3C0D"
|
|
97
|
-
}
|
|
96
|
+
}
|
package/scripts/inject-path.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
|
-
import dotenv from "dotenv";
|
|
7
6
|
import {
|
|
8
7
|
askConfirmation,
|
|
9
8
|
createReadlineInterface,
|
|
@@ -11,9 +10,6 @@ import {
|
|
|
11
10
|
gitExec
|
|
12
11
|
} from "./utils.js";
|
|
13
12
|
|
|
14
|
-
// Load environment variables from .env file
|
|
15
|
-
dotenv.config();
|
|
16
|
-
|
|
17
13
|
const rl = createReadlineInterface();
|
|
18
14
|
|
|
19
15
|
interface InjectionPlan {
|
|
@@ -133,7 +129,7 @@ async function ensurePluginConfigClean(): Promise<void> {
|
|
|
133
129
|
const currentBranch = execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" }).trim();
|
|
134
130
|
gitExec(`git push --set-upstream origin ${currentBranch}`);
|
|
135
131
|
console.log(`✅ New branch pushed with upstream set`);
|
|
136
|
-
} catch
|
|
132
|
+
} catch {
|
|
137
133
|
console.log(`⚠️ Changes committed locally but push failed. Continue with injection.`);
|
|
138
134
|
}
|
|
139
135
|
}
|
|
@@ -150,34 +146,13 @@ async function ensurePluginConfigClean(): Promise<void> {
|
|
|
150
146
|
* Find plugin-config root directory
|
|
151
147
|
*/
|
|
152
148
|
function findPluginConfigRoot(): string {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// Option 1: local - check parent directory
|
|
156
|
-
if (envPath === "local") {
|
|
157
|
-
const parentPath = path.resolve(process.cwd(), "../obsidian-plugin-config");
|
|
158
|
-
if (fs.existsSync(parentPath)) {
|
|
159
|
-
return parentPath;
|
|
160
|
-
}
|
|
161
|
-
throw new Error("obsidian-plugin-config not found in parent directory");
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Option 2: prompt - skip auto-detection
|
|
165
|
-
if (envPath === "prompt") {
|
|
166
|
-
throw new Error("PROMPT_REQUIRED");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Option 3: specific path
|
|
170
|
-
if (envPath && fs.existsSync(envPath)) {
|
|
171
|
-
return envPath;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Option 4: auto-detect parent, fallback to current
|
|
149
|
+
// Option 1: auto-detect parent directory
|
|
175
150
|
const parentPath = path.resolve(process.cwd(), "../obsidian-plugin-config");
|
|
176
151
|
if (fs.existsSync(parentPath)) {
|
|
177
152
|
return parentPath;
|
|
178
153
|
}
|
|
179
154
|
|
|
180
|
-
// Option
|
|
155
|
+
// Option 2: Check if we're running from NPM package (global installation)
|
|
181
156
|
// Get the directory of this script file
|
|
182
157
|
const scriptDir = path.dirname(new URL(import.meta.url).pathname);
|
|
183
158
|
const npmPackageRoot = path.resolve(scriptDir, "..");
|
|
@@ -214,21 +189,20 @@ function copyFromLocal(filePath: string): string {
|
|
|
214
189
|
}
|
|
215
190
|
|
|
216
191
|
/**
|
|
217
|
-
* Clean old script files (remove
|
|
192
|
+
* Clean old script files (remove existing scripts to ensure clean injection)
|
|
218
193
|
*/
|
|
219
194
|
async function cleanOldScripts(scriptsPath: string): Promise<void> {
|
|
220
195
|
const scriptNames = ["utils", "esbuild.config", "acp", "update-version", "release", "help"];
|
|
196
|
+
const extensions = [".ts", ".mts", ".js", ".mjs"];
|
|
221
197
|
|
|
222
|
-
// Remove
|
|
198
|
+
// Remove all existing script files with any extension
|
|
223
199
|
for (const scriptName of scriptNames) {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
} else if (await isValidPath(mtsFile)) {
|
|
231
|
-
console.log(`ℹ️ Found old ${scriptName}.mts file (will be replaced by ${scriptName}.ts)`);
|
|
200
|
+
for (const ext of extensions) {
|
|
201
|
+
const scriptFile = path.join(scriptsPath, `${scriptName}${ext}`);
|
|
202
|
+
if (await isValidPath(scriptFile)) {
|
|
203
|
+
fs.unlinkSync(scriptFile);
|
|
204
|
+
console.log(`🗑️ Removed existing ${scriptName}${ext} (will be replaced)`);
|
|
205
|
+
}
|
|
232
206
|
}
|
|
233
207
|
}
|
|
234
208
|
|
|
@@ -605,82 +579,7 @@ function readInjectionInfo(targetPath: string): any | null {
|
|
|
605
579
|
}
|
|
606
580
|
}
|
|
607
581
|
|
|
608
|
-
/**
|
|
609
|
-
* Check if tsx is available and install it if needed
|
|
610
|
-
*/
|
|
611
|
-
async function ensureTsxAvailable(targetPath: string): Promise<void> {
|
|
612
|
-
console.log(`\n🔍 Checking tsx availability...`);
|
|
613
582
|
|
|
614
|
-
try {
|
|
615
|
-
// Check if tsx is available globally
|
|
616
|
-
try {
|
|
617
|
-
execSync('tsx --version', { stdio: 'pipe' });
|
|
618
|
-
console.log(` ✅ tsx is available globally`);
|
|
619
|
-
return;
|
|
620
|
-
} catch {
|
|
621
|
-
// tsx not available globally, continue to check locally
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// Check if tsx is available locally in target
|
|
625
|
-
try {
|
|
626
|
-
execSync('npx tsx --version', {
|
|
627
|
-
cwd: targetPath,
|
|
628
|
-
stdio: 'pipe'
|
|
629
|
-
});
|
|
630
|
-
console.log(` ✅ tsx is available locally`);
|
|
631
|
-
return;
|
|
632
|
-
} catch {
|
|
633
|
-
// tsx not available locally, need to install
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
console.log(` ⚠️ tsx not found, installing as dev dependency...`);
|
|
637
|
-
|
|
638
|
-
// Install tsx as dev dependency
|
|
639
|
-
execSync('yarn add -D tsx', {
|
|
640
|
-
cwd: targetPath,
|
|
641
|
-
stdio: 'inherit'
|
|
642
|
-
});
|
|
643
|
-
|
|
644
|
-
console.log(` ✅ tsx installed successfully`);
|
|
645
|
-
|
|
646
|
-
} catch (error) {
|
|
647
|
-
console.error(` ❌ Failed to install tsx: ${error}`);
|
|
648
|
-
console.log(` 💡 You may need to install tsx manually: yarn add -D tsx`);
|
|
649
|
-
throw new Error('tsx installation failed');
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Clean NPM artifacts to avoid conflicts with Yarn
|
|
655
|
-
*/
|
|
656
|
-
async function cleanNpmArtifacts(targetPath: string): Promise<void> {
|
|
657
|
-
console.log(`\n🧹 Cleaning NPM artifacts...`);
|
|
658
|
-
|
|
659
|
-
const packageLockPath = path.join(targetPath, "package-lock.json");
|
|
660
|
-
const nodeModulesPath = path.join(targetPath, "node_modules");
|
|
661
|
-
|
|
662
|
-
try {
|
|
663
|
-
// Remove package-lock.json if it exists
|
|
664
|
-
if (fs.existsSync(packageLockPath)) {
|
|
665
|
-
fs.unlinkSync(packageLockPath);
|
|
666
|
-
console.log(` 🗑️ Removed package-lock.json (NPM lock file)`);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
// Remove node_modules if it exists
|
|
670
|
-
if (fs.existsSync(nodeModulesPath)) {
|
|
671
|
-
fs.rmSync(nodeModulesPath, { recursive: true, force: true });
|
|
672
|
-
console.log(` 🗑️ Removed node_modules (will be reinstalled with Yarn)`);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
if (!fs.existsSync(packageLockPath) && !fs.existsSync(nodeModulesPath)) {
|
|
676
|
-
console.log(` ✅ No NPM artifacts found`);
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
} catch (error) {
|
|
680
|
-
console.error(` ❌ Failed to clean NPM artifacts: ${error}`);
|
|
681
|
-
console.log(` 💡 You may need to manually remove package-lock.json and node_modules`);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
583
|
|
|
685
584
|
/**
|
|
686
585
|
* Clean NPM artifacts if package-lock.json is found (evidence of NPM usage)
|
package/scripts/inject-prompt.ts
CHANGED
|
@@ -44,7 +44,7 @@ async function analyzePlugin(pluginPath: string): Promise<InjectionPlan> {
|
|
|
44
44
|
try {
|
|
45
45
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
46
46
|
plan.isObsidianPlugin = !!(manifest.id && manifest.name && manifest.version);
|
|
47
|
-
} catch
|
|
47
|
+
} catch {
|
|
48
48
|
console.warn("Warning: Could not parse manifest.json");
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -57,7 +57,7 @@ async function analyzePlugin(pluginPath: string): Promise<InjectionPlan> {
|
|
|
57
57
|
...Object.keys(packageJson.dependencies || {}),
|
|
58
58
|
...Object.keys(packageJson.devDependencies || {})
|
|
59
59
|
];
|
|
60
|
-
} catch
|
|
60
|
+
} catch {
|
|
61
61
|
console.warn("Warning: Could not parse package.json");
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -125,7 +125,7 @@ async function ensurePluginConfigClean(): Promise<void> {
|
|
|
125
125
|
const currentBranch = execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" }).trim();
|
|
126
126
|
gitExec(`git push --set-upstream origin ${currentBranch}`);
|
|
127
127
|
console.log(`✅ New branch pushed with upstream set`);
|
|
128
|
-
} catch
|
|
128
|
+
} catch {
|
|
129
129
|
console.log(`⚠️ Changes committed locally but push failed. Continue with injection.`);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -370,7 +370,7 @@ async function createInjectionInfo(targetPath: string): Promise<void> {
|
|
|
370
370
|
try {
|
|
371
371
|
const configPackageJson = JSON.parse(fs.readFileSync(configPackageJsonPath, "utf8"));
|
|
372
372
|
injectorVersion = configPackageJson.version || "unknown";
|
|
373
|
-
} catch
|
|
373
|
+
} catch {
|
|
374
374
|
console.warn("Warning: Could not read injector version");
|
|
375
375
|
}
|
|
376
376
|
|
package/src/main.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
App,
|
|
3
|
+
Plugin,
|
|
4
|
+
PluginSettingTab,
|
|
5
|
+
Setting,
|
|
6
|
+
Notice
|
|
7
|
+
} from "obsidian";
|
|
8
|
+
import { showConfirmModal } from "./modals/GenericConfirmModal.ts";
|
|
9
|
+
// import { showTestMessage, getRandomEmoji } from "obsidian-plugin-config/tools";
|
|
10
|
+
|
|
11
|
+
interface MyPluginSettings {
|
|
12
|
+
mySetting: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DEFAULT_SETTINGS: MyPluginSettings = {
|
|
16
|
+
mySetting: "default"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default class MyPlugin extends Plugin {
|
|
20
|
+
settings: MyPluginSettings;
|
|
21
|
+
|
|
22
|
+
async onload(): Promise<void> {
|
|
23
|
+
console.log("loading plugin");
|
|
24
|
+
await this.loadSettings();
|
|
25
|
+
|
|
26
|
+
this.addCommand({
|
|
27
|
+
id: 'show-confirmation-modal',
|
|
28
|
+
name: 'Show Confirmation Modal (Local)',
|
|
29
|
+
callback: () => this.showConfirmationModal()
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.addCommand({
|
|
33
|
+
id: 'show-centralized-modal',
|
|
34
|
+
name: 'Show Confirmation Modal (Centralized)',
|
|
35
|
+
callback: () => this.showCentralizedModal()
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
this.addCommand({
|
|
39
|
+
id: 'test-tools',
|
|
40
|
+
name: 'Test Centralized Tools',
|
|
41
|
+
callback: () => {
|
|
42
|
+
// const message = showTestMessage();
|
|
43
|
+
// const emoji = getRandomEmoji();
|
|
44
|
+
new Notice(`🎯 Test centralized tools (commented for autonomous mode)`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this.addSettingTab(new SampleSettingTab(this.app, this));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private showConfirmationModal(): void {
|
|
52
|
+
showConfirmModal(this.app, {
|
|
53
|
+
title: "Confirmation requise",
|
|
54
|
+
message: "Êtes-vous sûr de vouloir effectuer cette action ? Cette action ne peut pas être annulée.",
|
|
55
|
+
confirmText: "Confirmer",
|
|
56
|
+
cancelText: "Annuler",
|
|
57
|
+
onConfirm: () => {
|
|
58
|
+
new Notice("Action confirmée !");
|
|
59
|
+
console.log("Action confirmée par l'utilisateur");
|
|
60
|
+
},
|
|
61
|
+
onCancel: () => {
|
|
62
|
+
new Notice("Action annulée.");
|
|
63
|
+
console.log("Action annulée par l'utilisateur");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private showCentralizedModal(): void {
|
|
69
|
+
showConfirmModal(this.app, {
|
|
70
|
+
title: "Centralized Modal Test",
|
|
71
|
+
message: "This modal comes from the centralized configuration! Pretty cool, right?",
|
|
72
|
+
confirmText: "Awesome!",
|
|
73
|
+
cancelText: "Not bad",
|
|
74
|
+
onConfirm: () => {
|
|
75
|
+
new Notice("Centralized modal confirmed! 🎉");
|
|
76
|
+
},
|
|
77
|
+
onCancel: () => {
|
|
78
|
+
new Notice("Centralized modal cancelled 😢");
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async loadSettings(): Promise<void> {
|
|
84
|
+
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async saveSettings(): Promise<void> {
|
|
88
|
+
await this.saveData(this.settings);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
class SampleSettingTab extends PluginSettingTab {
|
|
93
|
+
plugin: MyPlugin;
|
|
94
|
+
|
|
95
|
+
constructor(app: App, plugin: MyPlugin) {
|
|
96
|
+
super(app, plugin);
|
|
97
|
+
this.plugin = plugin;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
display(): void {
|
|
101
|
+
const { containerEl } = this;
|
|
102
|
+
containerEl.empty();
|
|
103
|
+
new Setting(containerEl);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
@@ -167,7 +167,7 @@ export class SettingsHelper {
|
|
|
167
167
|
arrow.style.marginRight = "8px";
|
|
168
168
|
arrow.style.fontSize = "0.8em";
|
|
169
169
|
|
|
170
|
-
const toggle = () => {
|
|
170
|
+
const toggle = () : void => {
|
|
171
171
|
const isCurrentlyOpen = contentEl.style.display !== "none";
|
|
172
172
|
contentEl.style.display = isCurrentlyOpen ? "none" : "block";
|
|
173
173
|
arrow.setText(isCurrentlyOpen ? "▶" : "▼");
|
package/versions.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Simple test file to verify centralized utils work
|
|
2
|
-
// import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
3
|
-
|
|
4
|
-
export function testCentralizedUtils(): void {
|
|
5
|
-
console.log("🧪 Testing centralized utils (commented for autonomous mode)...");
|
|
6
|
-
|
|
7
|
-
// Test different notice types (commented for autonomous mode)
|
|
8
|
-
// NoticeHelper.success("✅ Centralized utils are working!");
|
|
9
|
-
|
|
10
|
-
// setTimeout(() => {
|
|
11
|
-
// NoticeHelper.info("ℹ️ This notice comes from the centralized config");
|
|
12
|
-
// }, 1000);
|
|
13
|
-
|
|
14
|
-
// setTimeout(() => {
|
|
15
|
-
// NoticeHelper.warning("⚠️ This is a warning from centralized utils");
|
|
16
|
-
// }, 2000);
|
|
17
|
-
|
|
18
|
-
// setTimeout(() => {
|
|
19
|
-
// NoticeHelper.custom("🚀", "Custom notice with rocket emoji!");
|
|
20
|
-
// }, 3000);
|
|
21
|
-
|
|
22
|
-
console.log("✅ All centralized utils tests completed (autonomous mode)!");
|
|
23
|
-
}
|