obsidian-plugin-config 1.3.2 → 1.3.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/bin/obsidian-inject.js +1 -1
- package/package.json +1 -1
- package/scripts/inject-core.ts +95 -45
- package/templates/env.template +10 -0
- package/templates/gitignore.template +34 -0
- package/templates/npmrc.template +2 -0
- package/versions.json +4 -1
package/bin/obsidian-inject.js
CHANGED
package/package.json
CHANGED
package/scripts/inject-core.ts
CHANGED
|
@@ -97,36 +97,66 @@ export function copyFromLocal(filePath: string): string {
|
|
|
97
97
|
*/
|
|
98
98
|
export async function ensurePluginConfigClean(): Promise<void> {
|
|
99
99
|
const configRoot = findPluginConfigRoot();
|
|
100
|
+
const gitDir = path.join(configRoot, ".git");
|
|
101
|
+
|
|
102
|
+
// Skip git check if not a git repo
|
|
103
|
+
// (e.g. NPM global install)
|
|
104
|
+
if (!fs.existsSync(gitDir)) {
|
|
105
|
+
console.log(
|
|
106
|
+
`✅ Plugin-config repo is clean` +
|
|
107
|
+
` (NPM install, no git check)`
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
100
112
|
const originalCwd = process.cwd();
|
|
101
113
|
|
|
102
114
|
try {
|
|
103
115
|
process.chdir(configRoot);
|
|
104
|
-
const gitStatus = execSync(
|
|
116
|
+
const gitStatus = execSync(
|
|
117
|
+
"git status --porcelain",
|
|
118
|
+
{ encoding: "utf8" }
|
|
119
|
+
).trim();
|
|
105
120
|
|
|
106
121
|
if (gitStatus) {
|
|
107
|
-
console.log(
|
|
122
|
+
console.log(
|
|
123
|
+
`\n⚠️ Plugin-config has uncommitted changes:`
|
|
124
|
+
);
|
|
108
125
|
console.log(gitStatus);
|
|
109
|
-
console.log(
|
|
126
|
+
console.log(
|
|
127
|
+
`\n🔧 Auto-committing changes...`
|
|
128
|
+
);
|
|
110
129
|
|
|
111
|
-
const
|
|
130
|
+
const msg =
|
|
131
|
+
"🔧 Update plugin-config templates";
|
|
112
132
|
gitExec("git add -A");
|
|
113
|
-
gitExec(`git commit -m "${
|
|
133
|
+
gitExec(`git commit -m "${msg}"`);
|
|
114
134
|
|
|
115
135
|
try {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
136
|
+
const branch = execSync(
|
|
137
|
+
"git rev-parse --abbrev-ref HEAD",
|
|
138
|
+
{ encoding: "utf8" }
|
|
139
|
+
).trim();
|
|
140
|
+
gitExec(`git push origin ${branch}`);
|
|
141
|
+
console.log(
|
|
142
|
+
`✅ Changes committed and pushed`
|
|
143
|
+
);
|
|
121
144
|
} catch {
|
|
122
145
|
try {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
146
|
+
const branch = execSync(
|
|
147
|
+
"git rev-parse --abbrev-ref HEAD",
|
|
148
|
+
{ encoding: "utf8" }
|
|
149
|
+
).trim();
|
|
150
|
+
gitExec(
|
|
151
|
+
`git push --set-upstream origin ${branch}`
|
|
152
|
+
);
|
|
153
|
+
console.log(
|
|
154
|
+
`✅ New branch pushed with upstream`
|
|
155
|
+
);
|
|
128
156
|
} catch {
|
|
129
|
-
console.log(
|
|
157
|
+
console.log(
|
|
158
|
+
`⚠️ Committed locally, push failed`
|
|
159
|
+
);
|
|
130
160
|
}
|
|
131
161
|
}
|
|
132
162
|
} else {
|
|
@@ -263,17 +293,25 @@ export async function injectScripts(targetPath: string, useSass: boolean = false
|
|
|
263
293
|
"templates/scripts/help.ts"
|
|
264
294
|
];
|
|
265
295
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
"templates
|
|
271
|
-
"templates
|
|
272
|
-
"templates
|
|
273
|
-
"templates/.
|
|
274
|
-
"templates/.
|
|
275
|
-
"templates
|
|
276
|
-
|
|
296
|
+
// Files with .template suffix are renamed by NPM
|
|
297
|
+
// exclusion rules (.gitignore, .npmrc, .env)
|
|
298
|
+
// Map: { source: targetName }
|
|
299
|
+
const configFileMap: Record<string, string> = {
|
|
300
|
+
"templates/tsconfig.json": "tsconfig.json",
|
|
301
|
+
"templates/gitignore.template": ".gitignore",
|
|
302
|
+
"templates/eslint.config.mts": "eslint.config.mts",
|
|
303
|
+
"templates/.editorconfig": ".editorconfig",
|
|
304
|
+
"templates/.prettierrc": ".prettierrc",
|
|
305
|
+
"templates/npmrc.template": ".npmrc",
|
|
306
|
+
"templates/env.template": ".env",
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const configVscodeMap: Record<string, string> = {
|
|
310
|
+
"templates/.vscode/settings.json":
|
|
311
|
+
".vscode/settings.json",
|
|
312
|
+
"templates/.vscode/tasks.json":
|
|
313
|
+
".vscode/tasks.json",
|
|
314
|
+
};
|
|
277
315
|
|
|
278
316
|
const workflowFiles = [
|
|
279
317
|
"templates/.github/workflows/release.yml",
|
|
@@ -294,33 +332,45 @@ export async function injectScripts(targetPath: string, useSass: boolean = false
|
|
|
294
332
|
}
|
|
295
333
|
}
|
|
296
334
|
|
|
297
|
-
console.log(`\n📥 Copying config files
|
|
335
|
+
console.log(`\n📥 Copying config files...`);
|
|
298
336
|
|
|
299
|
-
|
|
337
|
+
// Copy root config files
|
|
338
|
+
for (const [src, destName] of Object.entries(
|
|
339
|
+
configFileMap
|
|
340
|
+
)) {
|
|
300
341
|
try {
|
|
301
|
-
const content = copyFromLocal(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
342
|
+
const content = copyFromLocal(src);
|
|
343
|
+
const targetFile = path.join(
|
|
344
|
+
targetPath, destName
|
|
345
|
+
);
|
|
346
|
+
fs.writeFileSync(targetFile, content, "utf8");
|
|
347
|
+
console.log(` ✅ ${destName}`);
|
|
348
|
+
} catch (error) {
|
|
349
|
+
console.error(
|
|
350
|
+
` ❌ Failed to inject ${destName}: ${error}`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
314
354
|
|
|
355
|
+
// Copy .vscode config files
|
|
356
|
+
for (const [src, destName] of Object.entries(
|
|
357
|
+
configVscodeMap
|
|
358
|
+
)) {
|
|
359
|
+
try {
|
|
360
|
+
const content = copyFromLocal(src);
|
|
361
|
+
const targetFile = path.join(
|
|
362
|
+
targetPath, destName
|
|
363
|
+
);
|
|
315
364
|
const targetDir = path.dirname(targetFile);
|
|
316
365
|
if (!await isValidPath(targetDir)) {
|
|
317
366
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
318
367
|
}
|
|
319
|
-
|
|
320
368
|
fs.writeFileSync(targetFile, content, "utf8");
|
|
321
|
-
console.log(` ✅ ${
|
|
369
|
+
console.log(` ✅ ${destName}`);
|
|
322
370
|
} catch (error) {
|
|
323
|
-
console.error(
|
|
371
|
+
console.error(
|
|
372
|
+
` ❌ Failed to inject ${destName}: ${error}`
|
|
373
|
+
);
|
|
324
374
|
}
|
|
325
375
|
}
|
|
326
376
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Environment variables for plugin development
|
|
2
|
+
# Update these paths to match your setup
|
|
3
|
+
|
|
4
|
+
# Path to test vault (for development)
|
|
5
|
+
TEST_VAULT=
|
|
6
|
+
|
|
7
|
+
# Path to real vault (for production testing)
|
|
8
|
+
REAL_VAULT=
|
|
9
|
+
|
|
10
|
+
# Note: Run 'yarn version' to update these paths interactively
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Intellij
|
|
2
|
+
*.iml
|
|
3
|
+
.idea
|
|
4
|
+
|
|
5
|
+
# npm
|
|
6
|
+
node_modules
|
|
7
|
+
package-lock.json
|
|
8
|
+
|
|
9
|
+
# yarn - keep yarn.lock for version consistency
|
|
10
|
+
# yarn.lock
|
|
11
|
+
|
|
12
|
+
# Don't include the compiled main.js file in the repo.
|
|
13
|
+
# They should be uploaded to GitHub releases instead.
|
|
14
|
+
main.js
|
|
15
|
+
|
|
16
|
+
# Exclude sourcemaps
|
|
17
|
+
*.map
|
|
18
|
+
|
|
19
|
+
# obsidian
|
|
20
|
+
data.json
|
|
21
|
+
|
|
22
|
+
# Exclude macOS Finder (System Explorer) View States
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# scss result
|
|
26
|
+
main.css
|
|
27
|
+
|
|
28
|
+
# VSCode - keep settings.json for yarn protection
|
|
29
|
+
.vscode/*
|
|
30
|
+
!.vscode/settings.json
|
|
31
|
+
!.vscode/tasks.json
|
|
32
|
+
|
|
33
|
+
# Keep injection info for traceability
|
|
34
|
+
# .injection-info.json should be committed to track injection version
|