obsidian-plugin-config 1.1.5 → 1.1.7
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 +69 -91
- package/package.json +11 -12
- package/scripts/help.ts +19 -31
- package/src/main.ts +106 -0
- package/versions.json +3 -1
- package/src/main_test.ts +0 -0
- package/src/test-centralized-utils.ts +0 -23
package/README.md
CHANGED
|
@@ -1,117 +1,95 @@
|
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
## Installation Globale
|
|
8
|
+
## Installation
|
|
13
9
|
|
|
14
10
|
```bash
|
|
15
11
|
npm install -g obsidian-plugin-config
|
|
16
12
|
```
|
|
17
13
|
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
### Injection dans le répertoire courant
|
|
14
|
+
## Update
|
|
21
15
|
|
|
22
16
|
```bash
|
|
23
|
-
|
|
24
|
-
obsidian-inject
|
|
17
|
+
npm update -g obsidian-plugin-config
|
|
25
18
|
```
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
obsidian-inject ../mon-plugin
|
|
31
|
-
obsidian-inject "C:\chemin\vers\plugin"
|
|
32
|
-
```
|
|
20
|
+
## Commands
|
|
33
21
|
|
|
34
|
-
###
|
|
22
|
+
### For Plugin Config Development
|
|
35
23
|
|
|
36
24
|
```bash
|
|
37
|
-
#
|
|
38
|
-
yarn
|
|
39
|
-
yarn
|
|
25
|
+
# Development
|
|
26
|
+
yarn start # Install dependencies + update exports
|
|
27
|
+
yarn build # Build the project
|
|
28
|
+
yarn dev # Development build
|
|
29
|
+
yarn real # Build to real vault
|
|
30
|
+
|
|
31
|
+
# Git Operations
|
|
32
|
+
yarn acp # Add, commit, push
|
|
33
|
+
yarn bacp # Build + add, commit, push
|
|
34
|
+
yarn v # Update version
|
|
35
|
+
|
|
36
|
+
# NPM Publishing
|
|
37
|
+
yarn build-npm # Build NPM package
|
|
38
|
+
yarn publish-npm # Publish to NPM
|
|
39
|
+
|
|
40
|
+
# Help
|
|
41
|
+
yarn help # Show help
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
###
|
|
44
|
+
### For Plugin Injection
|
|
43
45
|
|
|
44
46
|
```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 :
|
|
47
|
+
# Interactive injection (recommended)
|
|
48
|
+
obsidian-inject
|
|
49
|
+
obsidian-inject ../my-plugin
|
|
50
|
+
yarn inject-prompt "../my-plugin"
|
|
76
51
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
52
|
+
# Automatic injection
|
|
53
|
+
obsidian-inject ../my-plugin --yes
|
|
54
|
+
yarn inject-path ../my-plugin --yes
|
|
80
55
|
|
|
81
|
-
|
|
82
|
-
|
|
56
|
+
# Verification only
|
|
57
|
+
yarn check-plugin ../my-plugin
|
|
83
58
|
```
|
|
84
59
|
|
|
85
|
-
|
|
60
|
+
## What is injected
|
|
61
|
+
|
|
62
|
+
- ✅ **Standalone local scripts**: `esbuild.config.ts`, `acp.ts`, `update-version.ts`, etc.
|
|
63
|
+
- ✅ **package.json configuration**: scripts, dependencies, yarn protection
|
|
64
|
+
- ✅ **tsconfig.json template**: modern optimized TypeScript configuration
|
|
65
|
+
- ✅ **Automatic installation** of dependencies with yarn
|
|
66
|
+
- ✅ **Traceability file**: `.injection-info.json` (version, injection date)
|
|
86
67
|
|
|
87
|
-
##
|
|
68
|
+
## Commands available after injection
|
|
88
69
|
|
|
89
70
|
```bash
|
|
90
|
-
yarn build #
|
|
91
|
-
yarn dev #
|
|
92
|
-
yarn start #
|
|
93
|
-
yarn real # Build
|
|
71
|
+
yarn build # Production build
|
|
72
|
+
yarn dev # Development build + watch
|
|
73
|
+
yarn start # Install dependencies + start dev
|
|
74
|
+
yarn real # Build to real vault
|
|
94
75
|
yarn acp # Add-commit-push
|
|
95
76
|
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
|
|
77
|
+
yarn v # Update version
|
|
78
|
+
yarn release # GitHub release
|
|
79
|
+
yarn help # Full help
|
|
102
80
|
```
|
|
103
81
|
|
|
104
82
|
## Architecture
|
|
105
83
|
|
|
106
|
-
|
|
84
|
+
The plugin becomes **100% STANDALONE** after injection:
|
|
107
85
|
|
|
108
|
-
- ❌ **
|
|
109
|
-
- ✅ **Scripts
|
|
110
|
-
- ✅ **
|
|
111
|
-
- ✅ **
|
|
112
|
-
- ✅ **Compatible
|
|
86
|
+
- ❌ **No external dependencies** required
|
|
87
|
+
- ✅ **Scripts integrated locally**
|
|
88
|
+
- ✅ **Updatable** via re-injection
|
|
89
|
+
- ✅ **Yarn protection** maintained
|
|
90
|
+
- ✅ **Compatible with all Obsidian plugins**
|
|
113
91
|
|
|
114
|
-
##
|
|
92
|
+
## Local Development (for contributors)
|
|
115
93
|
|
|
116
94
|
### Installation
|
|
117
95
|
|
|
@@ -121,37 +99,37 @@ cd obsidian-plugin-config
|
|
|
121
99
|
yarn install
|
|
122
100
|
```
|
|
123
101
|
|
|
124
|
-
###
|
|
102
|
+
### Local injection test
|
|
125
103
|
|
|
126
104
|
```bash
|
|
127
|
-
#
|
|
128
|
-
yarn inject ../
|
|
105
|
+
# Automatic injection
|
|
106
|
+
yarn inject ../my-plugin --yes
|
|
129
107
|
|
|
130
|
-
# Injection
|
|
131
|
-
yarn inject-prompt "../
|
|
108
|
+
# Injection with prompts
|
|
109
|
+
yarn inject-prompt "../my-plugin"
|
|
132
110
|
```
|
|
133
111
|
|
|
134
|
-
###
|
|
112
|
+
### Full workflow: Local → NPM
|
|
135
113
|
|
|
136
114
|
```bash
|
|
137
|
-
# 1.
|
|
115
|
+
# 1. Local development
|
|
138
116
|
yarn inject ../test-plugin --yes
|
|
139
117
|
|
|
140
|
-
# 2.
|
|
141
|
-
#
|
|
118
|
+
# 2. Fix ESM imports if necessary
|
|
119
|
+
# Example: "./utils.ts" → "./utils.js"
|
|
142
120
|
|
|
143
|
-
# 3. Build
|
|
121
|
+
# 3. Build and publish to NPM
|
|
144
122
|
yarn build-npm
|
|
145
123
|
yarn update-version
|
|
146
124
|
npm login
|
|
147
125
|
npm publish
|
|
148
126
|
```
|
|
149
127
|
|
|
150
|
-
###
|
|
128
|
+
### Maintenance commands
|
|
151
129
|
|
|
152
130
|
```bash
|
|
153
131
|
yarn acp # Add, commit, push
|
|
154
|
-
yarn update-version #
|
|
155
|
-
yarn build-npm # Build package
|
|
156
|
-
yarn help #
|
|
132
|
+
yarn update-version # Update version
|
|
133
|
+
yarn build-npm # Build NPM package
|
|
134
|
+
yarn help # Full help
|
|
157
135
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obsidian-plugin-config",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
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/help.ts
CHANGED
|
@@ -6,25 +6,31 @@ Injection system for autonomous Obsidian plugins
|
|
|
6
6
|
|
|
7
7
|
═══════════════════════════════════════════════════════════════════
|
|
8
8
|
|
|
9
|
-
📋
|
|
9
|
+
📋 PLUGIN CONFIG COMMANDS
|
|
10
|
+
|
|
11
|
+
DEVELOPMENT:
|
|
12
|
+
yarn start # Install dependencies + update exports
|
|
13
|
+
yarn build # Build the project
|
|
14
|
+
yarn dev # Development build
|
|
15
|
+
yarn real # Build to real vault
|
|
10
16
|
|
|
11
17
|
INJECTION:
|
|
12
|
-
yarn inject <path> --yes
|
|
13
|
-
yarn inject-prompt <path> #
|
|
18
|
+
yarn inject-path <path> --yes # Automatic injection
|
|
19
|
+
yarn inject-prompt <path> # Interactive injection with prompts
|
|
14
20
|
yarn check-plugin <path> # Verification without injection
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
yarn acp # Add, commit, push
|
|
22
|
+
GIT & VERSION:
|
|
23
|
+
yarn acp # Add, commit, push
|
|
18
24
|
yarn bacp # Build + add, commit, push
|
|
19
25
|
yarn v, update-version # Update version
|
|
20
|
-
|
|
26
|
+
|
|
27
|
+
NPM PUBLISHING:
|
|
21
28
|
yarn build-npm # Build NPM package
|
|
22
|
-
yarn
|
|
23
|
-
yarn run help, h # This help
|
|
29
|
+
yarn publish-npm # Publish to NPM
|
|
24
30
|
|
|
25
31
|
═══════════════════════════════════════════════════════════════════
|
|
26
32
|
|
|
27
|
-
🔧
|
|
33
|
+
🔧 INJECTION USAGE
|
|
28
34
|
|
|
29
35
|
Recommended structure:
|
|
30
36
|
my-plugins/
|
|
@@ -33,29 +39,11 @@ Recommended structure:
|
|
|
33
39
|
└── my-plugin-2/
|
|
34
40
|
|
|
35
41
|
Usage:
|
|
36
|
-
yarn inject ../my-plugin
|
|
37
|
-
yarn
|
|
38
|
-
|
|
39
|
-
═══════════════════════════════════════════════════════════════════
|
|
40
|
-
|
|
41
|
-
✅ WHAT IS INJECTED
|
|
42
|
-
|
|
43
|
-
Autonomous scripts:
|
|
44
|
-
✅ utils.ts, acp.ts, release.ts, update-version.ts
|
|
45
|
-
✅ esbuild.config.ts, help.ts
|
|
46
|
-
✅ TypeScript and ESLint configuration
|
|
47
|
-
✅ GitHub Actions workflows (Yarn)
|
|
48
|
-
✅ Automatic Git sync verification
|
|
49
|
-
|
|
50
|
-
Result: 100% autonomous plugin, no external dependencies
|
|
42
|
+
yarn inject-prompt ../my-plugin # Interactive (recommended)
|
|
43
|
+
yarn inject-path ../my-plugin # Direct injection
|
|
44
|
+
yarn check-plugin ../my-plugin # Verification only
|
|
51
45
|
|
|
52
46
|
═══════════════════════════════════════════════════════════════════
|
|
53
47
|
|
|
54
|
-
📦 NPM WORKFLOW (when stable)
|
|
55
|
-
|
|
56
|
-
1. yarn build-npm # Build package
|
|
57
|
-
2. yarn v # Update version
|
|
58
|
-
3. npm publish # Publish (requires npm login)
|
|
59
|
-
|
|
60
|
-
CURRENT VERSION: 1.0.6
|
|
61
48
|
`);
|
|
49
|
+
|
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
|
+
|
package/versions.json
CHANGED
package/src/main_test.ts
DELETED
|
File without changes
|
|
@@ -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
|
-
}
|