obsidian-plugin-config 1.7.1 → 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.
- package/README.md +205 -205
- package/bin/obsidian-inject.js +1 -1
- package/docs/LLM-GUIDE.md +130 -130
- package/package.json +1 -1
- package/scripts/build-npm.ts +393 -393
- package/scripts/help.ts +87 -87
- package/scripts/inject-core.ts +897 -897
- package/scripts/inject-path.ts +156 -156
- package/scripts/inject-prompt.ts +104 -104
- package/scripts/utils.ts +151 -151
- package/tsconfig.json +2 -2
package/docs/LLM-GUIDE.md
CHANGED
|
@@ -1,130 +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/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.
|
|
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.
|