obsidian-plugin-config 1.0.3 → 1.0.5
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 +2 -2
- package/scripts/esbuild.config.ts +9 -0
- package/scripts/help.ts +146 -30
- package/scripts/inject-path.ts +16 -0
- package/scripts/inject-prompt.ts +3 -0
- package/src/main_test.ts +5 -5
- package/src/test-centralized-utils.ts +19 -19
- package/versions.json +3 -1
- package/scripts/open-editor.mjs +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "obsidian-plugin-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Système d'injection pour plugins Obsidian autonomes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"help": "tsx scripts/help.ts",
|
|
33
33
|
"h": "tsx scripts/help.ts",
|
|
34
34
|
"dev": "tsx scripts/esbuild.config.ts",
|
|
35
|
-
"build": "tsc -noEmit -skipLibCheck
|
|
35
|
+
"build": "tsc -noEmit -skipLibCheck",
|
|
36
36
|
"real": "tsx scripts/esbuild.config.ts production real",
|
|
37
37
|
"bacp": "tsx scripts/acp.ts -b",
|
|
38
38
|
"release": "tsx scripts/release.ts",
|
|
@@ -5,6 +5,7 @@ import { config } from "dotenv";
|
|
|
5
5
|
import path from "path";
|
|
6
6
|
import { readFileSync } from "fs";
|
|
7
7
|
import { rm } from "fs/promises";
|
|
8
|
+
import fs from "fs";
|
|
8
9
|
import { isValidPath, copyFilesToTargetDir, askQuestion, createReadlineInterface } from "./utils.js";
|
|
9
10
|
|
|
10
11
|
// Determine the plugin directory (where the script is called from)
|
|
@@ -102,6 +103,14 @@ function getVaultPath(vaultPath: string): string {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
const manifestPath = path.join(pluginDir, "manifest.json");
|
|
106
|
+
|
|
107
|
+
// Check if manifest exists (for plugin-config itself, it might not exist)
|
|
108
|
+
if (!fs.existsSync(manifestPath)) {
|
|
109
|
+
console.log("⚠️ No manifest.json found - this script is designed for Obsidian plugins");
|
|
110
|
+
console.log(" If you're building plugin-config itself, use 'tsc' instead");
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
105
114
|
const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
106
115
|
|
|
107
116
|
config();
|
package/scripts/help.ts
CHANGED
|
@@ -1,46 +1,162 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
3
|
console.log(`
|
|
4
|
-
Obsidian Plugin Config -
|
|
4
|
+
🎯 Obsidian Plugin Config - Guide Complet
|
|
5
5
|
Système d'injection pour plugins Obsidian autonomes
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install -g obsidian-plugin-config # Installation globale (une seule fois)
|
|
9
|
-
obsidian-inject # Injection depuis n'importe où
|
|
10
|
-
obsidian-inject /chemin/vers/plugin # Injection par chemin
|
|
7
|
+
═══════════════════════════════════════════════════════════════════
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
yarn inject-path <chemin> Injection par chemin depuis plugin-config
|
|
14
|
-
yarn inject <chemin> Alias pour inject-path
|
|
9
|
+
🚀 UTILISATION RAPIDE (NPM Global)
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
Installation globale (une seule fois):
|
|
12
|
+
npm install -g obsidian-plugin-config
|
|
13
|
+
|
|
14
|
+
Injection dans un plugin:
|
|
15
|
+
cd mon-plugin && obsidian-inject
|
|
16
|
+
obsidian-inject ../autre-plugin
|
|
17
|
+
obsidian-inject "C:\\chemin\\vers\\plugin"
|
|
18
|
+
|
|
19
|
+
═══════════════════════════════════════════════════════════════════
|
|
20
|
+
|
|
21
|
+
🔧 DÉVELOPPEMENT LOCAL
|
|
22
|
+
|
|
23
|
+
Structure recommandée:
|
|
24
|
+
mes-plugins/
|
|
25
|
+
├── obsidian-plugin-config/ # Ce repo
|
|
26
|
+
├── mon-plugin-1/
|
|
27
|
+
├── mon-plugin-2/
|
|
28
|
+
└── test-sample-plugin/ # Pour tests
|
|
29
|
+
|
|
30
|
+
Installation:
|
|
31
|
+
git clone https://github.com/3C0D/obsidian-plugin-config
|
|
32
|
+
cd obsidian-plugin-config
|
|
33
|
+
yarn install
|
|
34
|
+
|
|
35
|
+
Test injection locale:
|
|
36
|
+
yarn inject ../mon-plugin --yes
|
|
37
|
+
yarn inject-prompt "../mon-plugin"
|
|
38
|
+
|
|
39
|
+
═══════════════════════════════════════════════════════════════════
|
|
40
|
+
|
|
41
|
+
📦 WORKFLOW COMPLET : Local → NPM Package
|
|
42
|
+
|
|
43
|
+
ÉTAPE 1 - Développement Local:
|
|
44
|
+
cd obsidian-plugin-config
|
|
45
|
+
# Modifier scripts/ selon vos besoins
|
|
46
|
+
yarn inject ../test-plugin --yes
|
|
47
|
+
|
|
48
|
+
ÉTAPE 2 - Corrections Obligatoires:
|
|
49
|
+
# Corriger TOUS les imports dans scripts/
|
|
50
|
+
# Changer .ts → .js dans les imports
|
|
51
|
+
# Exemple: "./utils.ts" → "./utils.js"
|
|
52
|
+
|
|
53
|
+
ÉTAPE 3 - Build NPM:
|
|
54
|
+
yarn build-npm # Corrige automatiquement
|
|
55
|
+
yarn update-version # Choisir p/min/maj
|
|
56
|
+
|
|
57
|
+
ÉTAPE 4 - Test Local Package:
|
|
58
|
+
npm pack
|
|
59
|
+
npm install -g ./obsidian-plugin-config-X.X.X.tgz
|
|
60
|
+
obsidian-inject ../test-plugin # Tester commande globale
|
|
61
|
+
|
|
62
|
+
ÉTAPE 5 - Publication NPM:
|
|
63
|
+
npm login # OBLIGATOIRE !
|
|
64
|
+
npm publish # Après connexion réussie
|
|
65
|
+
|
|
66
|
+
═══════════════════════════════════════════════════════════════════
|
|
67
|
+
|
|
68
|
+
🔑 CONNEXION NPM - Points Critiques
|
|
69
|
+
|
|
70
|
+
PRÉREQUIS OBLIGATOIRES:
|
|
71
|
+
✅ Compte NPM sur https://www.npmjs.com
|
|
72
|
+
✅ Email vérifié
|
|
73
|
+
✅ 2FA activé (obligatoire pour publier)
|
|
74
|
+
✅ Nom de package disponible
|
|
75
|
+
|
|
76
|
+
RÉSOLUTION PROBLÈMES:
|
|
77
|
+
npm logout
|
|
78
|
+
npm login --registry https://registry.npmjs.org/
|
|
79
|
+
npm whoami # Vérifier connexion
|
|
80
|
+
npm profile enable-2fa auth-and-writes
|
|
81
|
+
|
|
82
|
+
CONTOURNEMENTS TESTÉS:
|
|
83
|
+
✅ Développement local : Fonctionne sans connexion
|
|
84
|
+
✅ Test npm pack : Fonctionne sans connexion
|
|
85
|
+
❌ Publication : Connexion NPM OBLIGATOIRE (pas de contournement)
|
|
86
|
+
|
|
87
|
+
═══════════════════════════════════════════════════════════════════
|
|
88
|
+
|
|
89
|
+
🔄 WORKFLOW MISE À JOUR
|
|
90
|
+
|
|
91
|
+
Pour futures modifications:
|
|
92
|
+
1. cd obsidian-plugin-config
|
|
93
|
+
2. Modifier scripts/...
|
|
94
|
+
3. yarn inject ../test-plugin --yes
|
|
95
|
+
4. Corriger imports (.ts → .js)
|
|
96
|
+
5. yarn build-npm
|
|
97
|
+
6. yarn update-version
|
|
98
|
+
7. npm pack && npm install -g ./package.tgz
|
|
99
|
+
8. npm publish
|
|
100
|
+
|
|
101
|
+
═══════════════════════════════════════════════════════════════════
|
|
102
|
+
|
|
103
|
+
🏗️ ADAPTATION PERSONNALISÉE
|
|
104
|
+
|
|
105
|
+
Pour créer votre propre version:
|
|
106
|
+
1. git clone https://github.com/3C0D/obsidian-plugin-config
|
|
107
|
+
2. Modifier package.json (nom, version, etc.)
|
|
108
|
+
3. Adapter scripts/ selon vos besoins
|
|
109
|
+
4. Adapter templates/ (configurations par défaut)
|
|
110
|
+
5. Tester: yarn inject ../votre-plugin --yes
|
|
111
|
+
6. Publier votre package: npm publish
|
|
112
|
+
|
|
113
|
+
═══════════════════════════════════════════════════════════════════
|
|
114
|
+
|
|
115
|
+
📋 COMMANDES DISPONIBLES
|
|
116
|
+
|
|
117
|
+
INJECTION:
|
|
118
|
+
yarn inject <chemin> --yes # Injection automatique
|
|
119
|
+
yarn inject-prompt <chemin> # Injection avec prompts
|
|
19
120
|
|
|
20
121
|
MAINTENANCE:
|
|
21
|
-
yarn acp
|
|
22
|
-
yarn update-version, v
|
|
23
|
-
yarn
|
|
122
|
+
yarn acp # Add, commit, push
|
|
123
|
+
yarn update-version, v # Mise à jour version
|
|
124
|
+
yarn build-npm # Build package NPM
|
|
125
|
+
yarn help, h # Cette aide
|
|
24
126
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
127
|
+
═══════════════════════════════════════════════════════════════════
|
|
128
|
+
|
|
129
|
+
✅ CE QUI EST INJECTÉ
|
|
130
|
+
|
|
131
|
+
Scripts locaux autonomes:
|
|
132
|
+
✅ esbuild.config.ts (build production/dev)
|
|
133
|
+
✅ acp.ts (add-commit-push)
|
|
134
|
+
✅ update-version.ts (gestion versions)
|
|
135
|
+
✅ release.ts (releases GitHub)
|
|
136
|
+
✅ help.ts (aide locale)
|
|
137
|
+
✅ utils.ts (utilitaires partagés)
|
|
138
|
+
|
|
139
|
+
Configuration:
|
|
140
|
+
✅ package.json (scripts, dépendances, protection yarn)
|
|
141
|
+
✅ tsconfig.json (configuration TypeScript optimisée)
|
|
142
|
+
✅ Installation automatique dépendances
|
|
143
|
+
|
|
144
|
+
Résultat:
|
|
145
|
+
✅ Plugin 100% AUTONOME
|
|
146
|
+
✅ Aucune dépendance externe
|
|
147
|
+
✅ Mise à jour via re-injection
|
|
148
|
+
✅ Compatible tous plugins Obsidian
|
|
29
149
|
|
|
30
|
-
|
|
31
|
-
yarn inject-path "../mon-plugin"
|
|
32
|
-
yarn inject "C:\\Users\\dev\\plugins\\mon-plugin"
|
|
150
|
+
═══════════════════════════════════════════════════════════════════
|
|
33
151
|
|
|
34
|
-
|
|
35
|
-
✅ Scripts locaux (esbuild.config.ts, acp.ts, utils.ts, etc.)
|
|
36
|
-
✅ Configuration package.json (scripts, dépendances)
|
|
37
|
-
✅ Protection yarn obligatoire
|
|
38
|
-
✅ Installation automatique des dépendances
|
|
152
|
+
⚠️ POINTS IMPORTANTS
|
|
39
153
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
154
|
+
- Toujours tester localement avant publication NPM
|
|
155
|
+
- Corriger les extensions .ts → .js dans les imports
|
|
156
|
+
- Connexion NPM obligatoire pour publier
|
|
157
|
+
- Sauvegarder vos modifications avant re-injection
|
|
158
|
+
- Utiliser yarn (protection intégrée)
|
|
44
159
|
|
|
45
160
|
COMPTE NPM: 3c0d (connecté)
|
|
161
|
+
VERSION: 1.0.4
|
|
46
162
|
`);
|
package/scripts/inject-path.ts
CHANGED
|
@@ -220,7 +220,9 @@ async function updatePackageJson(targetPath: string): Promise<void> {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
try {
|
|
223
|
+
console.log(` 🔍 Reading package.json from: ${packageJsonPath}`);
|
|
223
224
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
225
|
+
console.log(` 🔍 Original package name: ${packageJson.name}`);
|
|
224
226
|
|
|
225
227
|
// Update scripts
|
|
226
228
|
packageJson.scripts = {
|
|
@@ -284,6 +286,9 @@ async function updatePackageJson(targetPath: string): Promise<void> {
|
|
|
284
286
|
packageJson.engines.npm = "please-use-yarn";
|
|
285
287
|
packageJson.engines.yarn = ">=1.22.0";
|
|
286
288
|
|
|
289
|
+
// Ensure ESM module type for modern configuration
|
|
290
|
+
packageJson.type = "module";
|
|
291
|
+
|
|
287
292
|
// Write updated package.json
|
|
288
293
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
289
294
|
console.log(` ✅ Updated package.json (${addedDeps} new, ${updatedDeps} updated dependencies)`);
|
|
@@ -291,6 +296,11 @@ async function updatePackageJson(targetPath: string): Promise<void> {
|
|
|
291
296
|
// Debug: verify package.json was written correctly
|
|
292
297
|
console.log(` 🔍 Package name: ${packageJson.name}`);
|
|
293
298
|
|
|
299
|
+
// CRITICAL DEBUG: Re-read the file to verify what was actually written
|
|
300
|
+
const verifyContent = fs.readFileSync(packageJsonPath, 'utf8');
|
|
301
|
+
const verifyJson = JSON.parse(verifyContent);
|
|
302
|
+
console.log(` 🔍 VERIFICATION - File actually contains: ${verifyJson.name}`);
|
|
303
|
+
|
|
294
304
|
} catch (error) {
|
|
295
305
|
console.error(` ❌ Failed to update package.json: ${error}`);
|
|
296
306
|
}
|
|
@@ -417,6 +427,12 @@ export async function performInjection(targetPath: string): Promise<void> {
|
|
|
417
427
|
// Step 5: Install dependencies
|
|
418
428
|
await runYarnInstall(targetPath);
|
|
419
429
|
|
|
430
|
+
// FINAL DEBUG: Check package.json one last time
|
|
431
|
+
const finalPackageJsonPath = path.join(targetPath, "package.json");
|
|
432
|
+
const finalContent = fs.readFileSync(finalPackageJsonPath, 'utf8');
|
|
433
|
+
const finalJson = JSON.parse(finalContent);
|
|
434
|
+
console.log(`\n🔍 FINAL CHECK - Package name at end: ${finalJson.name}`);
|
|
435
|
+
|
|
420
436
|
console.log(`\n✅ Injection completed successfully!`);
|
|
421
437
|
console.log(`\n📋 Next steps:`);
|
|
422
438
|
console.log(` 1. cd ${targetPath}`);
|
package/scripts/inject-prompt.ts
CHANGED
|
@@ -249,6 +249,9 @@ async function updatePackageJson(targetPath: string): Promise<void> {
|
|
|
249
249
|
packageJson.engines.npm = "please-use-yarn";
|
|
250
250
|
packageJson.engines.yarn = ">=1.22.0";
|
|
251
251
|
|
|
252
|
+
// Ensure ESM module type for modern configuration
|
|
253
|
+
packageJson.type = "module";
|
|
254
|
+
|
|
252
255
|
// Write updated package.json
|
|
253
256
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
254
257
|
console.log(` ✅ Updated package.json (${addedDeps} new, ${updatedDeps} updated dependencies)`);
|
package/src/main_test.ts
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
Setting,
|
|
6
6
|
Notice
|
|
7
7
|
} from "obsidian";
|
|
8
|
-
import { showConfirmModal } from "./modals/GenericConfirmModal.
|
|
9
|
-
import { showTestMessage, getRandomEmoji } from "obsidian-plugin-config/tools";
|
|
8
|
+
import { showConfirmModal } from "./modals/GenericConfirmModal.js";
|
|
9
|
+
// import { showTestMessage, getRandomEmoji } from "obsidian-plugin-config/tools";
|
|
10
10
|
|
|
11
11
|
interface MyPluginSettings {
|
|
12
12
|
mySetting: string;
|
|
@@ -39,9 +39,9 @@ export default class MyPlugin extends Plugin {
|
|
|
39
39
|
id: 'test-tools',
|
|
40
40
|
name: 'Test Centralized Tools',
|
|
41
41
|
callback: () => {
|
|
42
|
-
const message = showTestMessage();
|
|
43
|
-
const emoji = getRandomEmoji();
|
|
44
|
-
new Notice(
|
|
42
|
+
// const message = showTestMessage();
|
|
43
|
+
// const emoji = getRandomEmoji();
|
|
44
|
+
new Notice(`🎯 Test centralized tools (commented for autonomous mode)`);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// Simple test file to verify centralized utils work
|
|
2
|
-
import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
2
|
+
// import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
3
3
|
|
|
4
4
|
export function testCentralizedUtils(): void {
|
|
5
|
-
console.log("🧪 Testing centralized utils...");
|
|
6
|
-
|
|
7
|
-
// Test different notice types
|
|
8
|
-
NoticeHelper.success("✅ Centralized utils are working!");
|
|
9
|
-
|
|
10
|
-
setTimeout(() => {
|
|
11
|
-
|
|
12
|
-
}, 1000);
|
|
13
|
-
|
|
14
|
-
setTimeout(() => {
|
|
15
|
-
|
|
16
|
-
}, 2000);
|
|
17
|
-
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
|
|
20
|
-
}, 3000);
|
|
21
|
-
|
|
22
|
-
console.log("✅ All centralized utils tests completed!");
|
|
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
23
|
}
|
package/versions.json
CHANGED
package/scripts/open-editor.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
2
|
-
import { platform } from 'os';
|
|
3
|
-
|
|
4
|
-
const isWindows = platform() === 'win32';
|
|
5
|
-
|
|
6
|
-
console.log(`Starting the ${process.env.npm_lifecycle_event} process...\n`);
|
|
7
|
-
console.log('- Dependencies installed');
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
if (isWindows) {
|
|
11
|
-
execSync("start /B code .", { stdio: "ignore", shell: true });
|
|
12
|
-
} else {
|
|
13
|
-
execSync("code .", { stdio: "ignore" });
|
|
14
|
-
}
|
|
15
|
-
console.log('- Opened current folder in VSCode');
|
|
16
|
-
} catch (error) {
|
|
17
|
-
console.warn('Warning: Could not open VSCode');
|
|
18
|
-
}
|