obsidian-plugin-config 1.7.0 → 1.7.2

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.
@@ -1,137 +1,76 @@
1
- # Système d'Injection Interactive
1
+ # Injection interactive
2
2
 
3
- ## Fonctionnalité Ajoutée
3
+ L'injection est **interactive par défaut** : elle compare chaque fichier du template
4
+ avec le fichier existant de la cible et ne demande confirmation que lorsque le contenu
5
+ diffère.
4
6
 
5
- Un système de sélection interactive permet maintenant de choisir quels fichiers injecter.
7
+ ## Points d'entrée
6
8
 
7
- ## Utilisation
8
-
9
- ### Mode par défaut (tout injecter)
10
- ```bash
11
- obsidian-inject ../my-plugin
12
- ```
13
-
14
- ### Mode interactif (choisir quoi injecter)
15
- ```bash
16
- obsidian-inject ../my-plugin --interactive
17
- # ou
18
- obsidian-inject ../my-plugin -i
19
- ```
20
-
21
- ### Presets rapides
22
9
  ```bash
23
- # Minimal : scripts + package.json + .env
24
- obsidian-inject ../my-plugin --preset=minimal
25
-
26
- # Scripts uniquement
27
- obsidian-inject ../my-plugin --preset=scripts-only
28
-
29
- # Config uniquement (tsconfig, eslint, prettier, etc.)
30
- obsidian-inject ../my-plugin --preset=config-only
10
+ # CLI globale
11
+ obsidian-inject # Injection dans le dossier courant
12
+ obsidian-inject ../my-plugin # Injection par chemin
13
+
14
+ # Scripts locaux (développement de ce repo)
15
+ yarn inject-prompt # Demande le chemin du plugin cible, puis injecte
16
+ yarn inject-path ../my-plugin # Injection directe par chemin
17
+ yarn check-plugin ../my-plugin # Dry-run (vérification seule, aucune modification)
31
18
  ```
32
19
 
33
- ## Options Disponibles
34
-
35
- Le mode interactif permet de choisir :
20
+ ## Comportement fichier par fichier
36
21
 
37
- 1. **scripts** - Scripts (esbuild.config.ts, acp.ts, utils.ts, etc.)
38
- 2. **packageJson** - package.json (scripts & dependencies)
39
- 3. **tsconfig** - tsconfig.json
40
- 4. **eslint** - eslint.config.mts
41
- 5. **prettier** - .prettierrc & .prettierignore
42
- 6. **editorconfig** - .editorconfig
43
- 7. **vscode** - .vscode/ (settings.json, tasks.json, extensions.json)
44
- 8. **github** - .github/workflows/ (release workflow)
45
- 9. **gitignore** - .gitignore
46
- 10. **env** - .env (template)
22
+ Pendant l'injection, chaque fichier est traité ainsi :
47
23
 
48
- ## Presets
24
+ - **La cible n'existe pas encore** → le fichier est injecté sans demander.
25
+ - **Contenu identique** → ignoré silencieusement (`✅ ... (unchanged)`).
26
+ - **Contenu différent** → l'outil demande `Update <fichier>? (content differs)`.
27
+ - `y` → le fichier est remplacé.
28
+ - `n` → le fichier existant est conservé (`⏭️ Kept existing ...`).
49
29
 
50
- ### minimal
51
- - ✅ scripts
52
- - ✅ packageJson
53
- - ✅ env
54
- - ❌ Tout le reste
30
+ Cas particuliers :
55
31
 
56
- ### scripts-only
57
- - scripts uniquement
58
- - Tout le reste
32
+ - `.env` est toujours **fusionné** : le template est réécrit en préservant les
33
+ valeurs déjà renseignées (chemins de vault, etc.).
34
+ - `.npmrc` est toujours injecté (protection Yarn).
35
+ - `eslint.config.mts` est approuvé automatiquement si un ancien `.eslintrc*`
36
+ est détecté (migration depuis l'ancien format).
59
37
 
60
- ### config-only
61
- - ✅ tsconfig
62
- - ✅ eslint
63
- - ✅ prettier
64
- - ✅ editorconfig
65
- - ✅ vscode
66
- - ✅ gitignore
67
- - ❌ scripts, packageJson, github, env
68
-
69
- ## Exemple d'Utilisation
38
+ ## Options
70
39
 
71
40
  ```bash
72
- # Lancer en mode interactif
73
- $ obsidian-inject ../my-plugin -i
74
-
75
- 🎯 Injection Options
76
- Select what you want to inject (default: all)
77
-
78
- Use default options (inject everything)? [Y/n]: n
79
-
80
- 📋 Select individual options:
81
-
82
- Inject Scripts (esbuild.config.ts, acp.ts, utils.ts, etc.)? [Y/n]: y
83
- Inject package.json (scripts & dependencies)? [Y/n]: y
84
- Inject tsconfig.json? [Y/n]: n
85
- Inject eslint.config.mts? [Y/n]: n
86
- Inject .prettierrc & .prettierignore? [Y/n]: y
87
- Inject .editorconfig? [Y/n]: y
88
- Inject .vscode/ (settings.json, tasks.json, extensions.json)? [Y/n]: y
89
- Inject .github/workflows/ (release workflow)? [Y/n]: n
90
- Inject .gitignore? [Y/n]: y
91
- Inject .env (template)? [Y/n]: y
92
-
93
- 📋 Selected options:
94
- ✅ Scripts (esbuild.config.ts, acp.ts, utils.ts, etc.)
95
- ✅ package.json (scripts & dependencies)
96
- ❌ tsconfig.json
97
- ❌ eslint.config.mts
98
- ✅ .prettierrc & .prettierignore
99
- ✅ .editorconfig
100
- ✅ .vscode/ (settings.json, tasks.json, extensions.json)
101
- ❌ .github/workflows/ (release workflow)
102
- ✅ .gitignore
103
- ✅ .env (template)
104
-
105
- Proceed with these options? [Y/n]: y
41
+ # Auto-confirmer tous les remplacements (aucune question)
42
+ obsidian-inject ../my-plugin --no # CLI globale : --no / -n
43
+ yarn inject-path ../my-plugin --yes # Scripts locaux : --yes / -y
44
+
45
+ # Vérification seule (n'écrit rien)
46
+ obsidian-inject ../my-plugin --dry-run
106
47
  ```
107
48
 
108
- ## Fichiers Concernés
49
+ | Option | Effet |
50
+ | ---------------- | -------------------------------------------------- |
51
+ | `--no`, `-n` | (CLI globale) auto-confirme tous les remplacements |
52
+ | `--yes`, `-y` | (scripts locaux) auto-confirme tous les remplacements |
53
+ | `--dry-run` | vérification seule, aucune modification |
109
54
 
110
- 1. **scripts/inject-core.ts** - Logique d'injection principale (options support)
111
- 2. **scripts/inject-prompt.ts** - Entrée interactive
112
- 3. **scripts/inject-path.ts** - Entrée CLI avec flags `--interactive` et `--preset`
55
+ ## Ce qui est injecté
113
56
 
114
- ## Cas d'Usage
57
+ Tous les fichiers du template sont pris en compte à chaque injection (pas de
58
+ sélection par composant) :
115
59
 
116
- ### Ne pas écraser esbuild.config.ts existant
117
- ```bash
118
- obsidian-inject ../my-plugin -i
119
- # Répondre 'n' à "Inject Scripts"
120
- ```
60
+ - `templates/scripts/*` `<cible>/scripts/`
61
+ - `templates/tsconfig.json`, `eslint.config.mts`, `.editorconfig`,
62
+ `.prettierrc`, `.prettierignore`, `.npmrc`, `.env`
63
+ - `templates/.vscode/*`
64
+ - `templates/.github/workflows/*`
65
+ - `templates/gitignore.template` → `<cible>/.gitignore`
121
66
 
122
- ### Injecter uniquement les configs
123
- ```bash
124
- obsidian-inject ../my-plugin --preset=config-only
125
- ```
126
-
127
- ### Tout sauf GitHub workflows
128
- ```bash
129
- obsidian-inject ../my-plugin -i
130
- # Répondre 'n' uniquement à ".github/workflows/"
131
- ```
67
+ La confirmation fichier par fichier permet de conserver un fichier existant
68
+ (par exemple un `esbuild.config.ts` personnalisé) en répondant `n` lorsque la
69
+ question apparaît.
132
70
 
133
- ## Notes
71
+ ## Fichiers concernés
134
72
 
135
- - Le fichier `.npmrc` est toujours injecté (protection Yarn)
136
- - En mode non-interactif, tout est injecté par défaut
137
- - Les options peuvent être combinées : `--interactive --sass`
73
+ 1. **scripts/inject-core.ts** logique d'injection (`diffAndPromptFiles`,
74
+ `injectScripts`, `updatePackageJson`, `performInjection`).
75
+ 2. **scripts/inject-prompt.ts** entrée interactive (demande le chemin).
76
+ 3. **scripts/inject-path.ts** — entrée CLI (parse `--yes`, `--dry-run`).
package/docs/LLM-GUIDE.md CHANGED
@@ -1,131 +1,130 @@
1
- # LLM Guide — obsidian-plugin-config
2
-
3
- ## What this tool does
4
-
5
- **obsidian-plugin-config** is a **pure injection tool** that copies scripts and configuration files into Obsidian plugins, making them 100% standalone.
6
-
7
- ---
8
-
9
- ## Architecture
10
-
11
- ### templates/ — Source of truth
12
-
13
- `templates/` contains everything that gets injected into target plugins:
14
-
15
- - `templates/scripts/` — scripts copied into `<target>/scripts/`
16
- - `templates/package.json` — base deps/scripts merged into `<target>/package.json`
17
- - `templates/package-sass.json` — additional deps merged when `--sass` flag is used
18
- - `templates/tsconfig.json` — TypeScript config injected as `<target>/tsconfig.json`
19
- - `templates/eslint.config.mts` — ESLint config injected into target
20
- - `templates/.editorconfig`, `templates/.prettierrc`, etc. config files injected into target
21
- - `templates/.github/workflows/` — GitHub Actions workflows
22
-
23
- ### scripts/ — Injection logic
24
-
25
- - `scripts/inject-core.ts` — main injection logic
26
- - `scripts/inject-path.ts` — CLI entry point (parses flags)
27
- - `scripts/inject-prompt.ts` — interactive injection
28
- - `scripts/build-npm.ts` — NPM publish workflow
29
- - `scripts/acp.ts`, `scripts/help.ts`, `scripts/update-version-config.ts`, `scripts/utils.ts` — utilities
30
-
31
- ### bin/ — Global CLI
32
-
33
- - `bin/obsidian-inject.js` — global CLI entry point (generated by build-npm.ts)
34
-
35
- ---
36
-
37
- ## What injection does
38
-
39
- ### 1. Package.json merge
40
-
41
- `inject-core.ts → updatePackageJson()` reads `templates/package.json` (and `templates/package-sass.json` if `--sass`) and merges into the target plugin's `package.json`:
42
-
43
- - All `scripts` are overwritten with template values
44
- - All `devDependencies` from template are added/updated
45
- - `engines` and `type` are set from template
46
- - Target plugin's own specific deps are preserved
47
-
48
- ### 2. File copying
49
-
50
- `inject-core.ts → injectScripts()` copies files from `templates/` into the target:
51
-
52
- - `templates/scripts/*` → `<target>/scripts/`
53
- - `templates/tsconfig.json` → `<target>/tsconfig.json`
54
- - `templates/eslint.config.mts` → `<target>/eslint.config.mts`
55
- - `templates/.editorconfig`, `.prettierrc`, `.npmrc`, `.env` → `<target>/`
56
- - `templates/.github/workflows/*` → `<target>/.github/workflows/`
57
- - `templates/gitignore.template` → `<target>/.gitignore`
58
-
59
- ### 3. Traceability
60
-
61
- Creates `.injection-info.json` in target with version and date.
62
-
63
- ---
64
-
65
- ## Template scripts
66
-
67
- Scripts in `templates/scripts/` that get copied to target plugins:
68
-
69
- **Build system (modular):**
70
- - `esbuild.config.ts` — build entry point, orchestrates all build modules
71
- - `constants.ts` — shared constants (external deps list, banner, REST port)
72
- - `env.ts` — environment validation, manifest check, build path resolution
73
- - `reload.ts` — Obsidian hot-reload via Local REST API
74
- - `typingsPlugin.ts` — esbuild plugin for obsidian-typings resolution
75
- - `utils.ts` — shared utilities (readline, file ops, git, vault path helpers)
76
-
77
- **Workflow scripts:**
78
- - `acp.ts` — add, commit, push workflow
79
- - `update-version.ts` — version bump utility
80
- - `release.ts` — GitHub release automation
81
- - `help.ts` — help documentation
82
-
83
- ---
84
-
85
- ## SASS support
86
-
87
- When `--sass` flag is used:
88
-
89
- 1. `templates/package-sass.json` deps are merged into target's `package.json`
90
- 2. Adds `esbuild-sass-plugin` dependency
91
- 3. The injected `esbuild.config.ts` automatically detects `.scss` files and uses the plugin
92
-
93
- Without `--sass`, the build still works — the SASS import in `esbuild.config.ts` is conditional and only activates if `.scss` files exist.
94
-
95
- ---
96
-
97
- ## What NOT to do
98
-
99
- - ❌ Do not hardcode deps/scripts in `inject-core.ts` they must come from `templates/package.json`
100
- - ❌ Do not modify root config files thinking it will affect injected plugins always modify `templates/`
101
- - ❌ Do not add `obsidian-plugin-config` as a dependency in `templates/package.json` — injected plugins are standalone
102
- - ❌ Do not inject `esbuild.config.ts` without its dependencies (`constants.ts`, `env.ts`, `reload.ts`, `typingsPlugin.ts`, `utils.ts`) — they are all required
103
-
104
- ---
105
-
106
- ## Updating injected content
107
-
108
- To change what gets injected:
109
-
110
- 1. Modify files in `templates/`
111
- 2. Test locally: `yarn inject-path ../test-plugin`
112
- 3. Publish: `yarn npm-publish`
113
- 4. Re-inject into existing plugins to update them
114
-
115
- ---
116
-
117
- ## obsidian-typings paths
118
-
119
- The correct paths for `obsidian-typings` in `templates/tsconfig.json`:
120
-
121
- ```json
122
- "types": ["obsidian-typings"],
123
- "paths": {
124
- "obsidian-typings/implementations": [
125
- "./node_modules/obsidian-typings/dist/cjs/implementations.d.cts",
126
- "./node_modules/obsidian-typings/dist/esm/implementations.mjs"
127
- ]
128
- }
129
- ```
130
-
131
- These must stay in sync with the actual `obsidian-typings` package structure.
1
+ # LLM Guide — obsidian-plugin-config
2
+
3
+ ## What this tool does
4
+
5
+ **obsidian-plugin-config** is a **pure injection tool** that copies scripts and configuration files into Obsidian plugins, making them 100% standalone.
6
+
7
+ ---
8
+
9
+ ## Architecture
10
+
11
+ ### templates/ — Source of truth
12
+
13
+ `templates/` contains everything that gets injected into target plugins:
14
+
15
+ - `templates/scripts/` — scripts copied into `<target>/scripts/`
16
+ - `templates/package.json` — base deps/scripts merged into `<target>/package.json`
17
+ - `templates/tsconfig.json` — TypeScript config injected as `<target>/tsconfig.json`
18
+ - `templates/eslint.config.mts` — ESLint config injected into target
19
+ - `templates/.editorconfig`, `templates/.prettierrc`, etc. — config files injected into target
20
+ - `templates/.github/workflows/`GitHub Actions workflows
21
+
22
+ ### scripts/ — Injection logic
23
+
24
+ - `scripts/inject-core.ts` — main injection logic
25
+ - `scripts/inject-path.ts` — CLI entry point (parses flags)
26
+ - `scripts/inject-prompt.ts` — interactive injection
27
+ - `scripts/build-npm.ts` — NPM publish workflow
28
+ - `scripts/acp.ts`, `scripts/help.ts`, `scripts/update-version-config.ts`, `scripts/utils.ts`utilities
29
+
30
+ ### bin/ — Global CLI
31
+
32
+ - `bin/obsidian-inject.js` — global CLI entry point (generated by build-npm.ts)
33
+
34
+ ---
35
+
36
+ ## What injection does
37
+
38
+ ### 1. Package.json merge
39
+
40
+ `inject-core.ts → updatePackageJson()` reads `templates/package.json` and merges into the target plugin's `package.json`:
41
+
42
+ - All `scripts` are overwritten with template values
43
+ - All `devDependencies` from template are added/updated
44
+ - `engines` and `type` are set from template
45
+ - Target plugin's own specific deps are preserved
46
+
47
+ ### 2. File copying
48
+
49
+ `inject-core.ts → injectScripts()` copies files from `templates/` into the target:
50
+
51
+ - `templates/scripts/*` → `<target>/scripts/`
52
+ - `templates/tsconfig.json` → `<target>/tsconfig.json`
53
+ - `templates/eslint.config.mts` → `<target>/eslint.config.mts`
54
+ - `templates/.editorconfig`, `.prettierrc`, `.npmrc`, `.env` → `<target>/`
55
+ - `templates/.github/workflows/*` → `<target>/.github/workflows/`
56
+ - `templates/gitignore.template` → `<target>/.gitignore`
57
+
58
+ ### 3. Traceability
59
+
60
+ Creates `.injection-info.json` in target with version and date.
61
+
62
+ ---
63
+
64
+ ## Template scripts
65
+
66
+ Scripts in `templates/scripts/` that get copied to target plugins:
67
+
68
+ **Build system (modular):**
69
+ - `esbuild.config.ts` — build entry point, orchestrates all build modules
70
+ - `constants.ts` — shared constants (external deps list, banner, REST port)
71
+ - `env.ts` — environment validation, manifest check, build path resolution
72
+ - `reload.ts` — Obsidian hot-reload via Local REST API
73
+ - `typingsPlugin.ts` — esbuild plugin for obsidian-typings resolution
74
+ - `utils.ts` — shared utilities (readline, file ops, git, vault path helpers)
75
+
76
+ **Workflow scripts:**
77
+ - `acp.ts` — add, commit, push workflow
78
+ - `update-version.ts` — version bump utility
79
+ - `release.ts` — GitHub release automation
80
+ - `help.ts` — help documentation
81
+
82
+ ---
83
+
84
+ ## SASS support
85
+
86
+ SCSS is handled automatically by the injected `esbuild.config.ts`:
87
+
88
+ 1. The build detects `.scss` files (e.g. `src/styles.scss`)
89
+ 2. When found, it dynamically imports `esbuild-sass-plugin` and compiles the SCSS
90
+ 3. The generated `main.css` is cleaned up after compilation
91
+
92
+ The `esbuild-sass-plugin` dependency is **not** injected automatically. If a plugin uses SCSS, install it once with `yarn add -D esbuild-sass-plugin` (the build prints a clear warning if it is missing). Plugins without `.scss` files build normally with no extra dependency.
93
+
94
+ ---
95
+
96
+ ## What NOT to do
97
+
98
+ - ❌ Do not hardcode deps/scripts in `inject-core.ts` — they must come from `templates/package.json`
99
+ - ❌ Do not modify root config files thinking it will affect injected plugins — always modify `templates/`
100
+ - ❌ Do not add `obsidian-plugin-config` as a dependency in `templates/package.json` injected plugins are standalone
101
+ - ❌ Do not inject `esbuild.config.ts` without its dependencies (`constants.ts`, `env.ts`, `reload.ts`, `typingsPlugin.ts`, `utils.ts`) they are all required
102
+
103
+ ---
104
+
105
+ ## Updating injected content
106
+
107
+ To change what gets injected:
108
+
109
+ 1. Modify files in `templates/`
110
+ 2. Test locally: `yarn inject-path ../test-plugin`
111
+ 3. Publish: `yarn npm-publish`
112
+ 4. Re-inject into existing plugins to update them
113
+
114
+ ---
115
+
116
+ ## obsidian-typings paths
117
+
118
+ The correct paths for `obsidian-typings` in `templates/tsconfig.json`:
119
+
120
+ ```json
121
+ "types": ["obsidian-typings"],
122
+ "paths": {
123
+ "obsidian-typings/implementations": [
124
+ "./node_modules/obsidian-typings/dist/cjs/implementations.d.cts",
125
+ "./node_modules/obsidian-typings/dist/esm/implementations.mjs"
126
+ ]
127
+ }
128
+ ```
129
+
130
+ These must stay in sync with the actual `obsidian-typings` package structure.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obsidian-plugin-config",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Global CLI injection tool for Obsidian plugins",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,6 @@
23
23
  "prettier": "prettier --check '**/*.{ts,json}'",
24
24
  "prettier:fix": "prettier --write '**/*.{ts,json}'",
25
25
  "inject-path": "tsx scripts/inject-path.ts",
26
- "inject-sass": "tsx scripts/inject-path.ts --sass",
27
26
  "inject-prompt": "tsx scripts/inject-prompt.ts",
28
27
  "inject": "tsx scripts/inject-prompt.ts",
29
28
  "check-plugin": "tsx scripts/inject-path.ts --dry-run",
package/scripts/acp.ts CHANGED
@@ -11,7 +11,7 @@ import {
11
11
 
12
12
  const rl = createReadlineInterface();
13
13
 
14
- // Check if we're in the centralized config repo
14
+ /** Check if we're in the centralized config repo */
15
15
  function isInCentralizedRepo(): boolean {
16
16
  const packageJsonPath = path.join(process.cwd(), 'package.json');
17
17
  if (!fs.existsSync(packageJsonPath)) return false;