obsidian-plugin-config 1.0.4 β 1.0.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/package.json +1 -1
- package/scripts/help.ts +146 -30
- package/scripts/inject-path.ts +21 -0
- package/scripts/inject-prompt.ts +3 -0
- package/versions.json +3 -1
- package/scripts/open-editor.mjs +0 -18
package/package.json
CHANGED
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
|
@@ -129,6 +129,24 @@ function findPluginConfigRoot(): string {
|
|
|
129
129
|
return parentPath;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
// Option 5: Check if we're running from NPM package (global installation)
|
|
133
|
+
// Get the directory of this script file
|
|
134
|
+
const scriptDir = path.dirname(new URL(import.meta.url).pathname);
|
|
135
|
+
const npmPackageRoot = path.resolve(scriptDir, "..");
|
|
136
|
+
|
|
137
|
+
// Check if we're in an NPM package structure
|
|
138
|
+
const npmPackageJson = path.join(npmPackageRoot, "package.json");
|
|
139
|
+
if (fs.existsSync(npmPackageJson)) {
|
|
140
|
+
try {
|
|
141
|
+
const packageContent = JSON.parse(fs.readFileSync(npmPackageJson, 'utf8'));
|
|
142
|
+
if (packageContent.name === "obsidian-plugin-config") {
|
|
143
|
+
return npmPackageRoot;
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
// Ignore parsing errors
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
// Fallback to current directory (original behavior)
|
|
133
151
|
return process.cwd();
|
|
134
152
|
}
|
|
@@ -286,6 +304,9 @@ async function updatePackageJson(targetPath: string): Promise<void> {
|
|
|
286
304
|
packageJson.engines.npm = "please-use-yarn";
|
|
287
305
|
packageJson.engines.yarn = ">=1.22.0";
|
|
288
306
|
|
|
307
|
+
// Ensure ESM module type for modern configuration
|
|
308
|
+
packageJson.type = "module";
|
|
309
|
+
|
|
289
310
|
// Write updated package.json
|
|
290
311
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
291
312
|
console.log(` β
Updated package.json (${addedDeps} new, ${updatedDeps} updated dependencies)`);
|
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/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
|
-
}
|