obsidian-plugin-config 1.3.0 β 1.3.3
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/help.ts +8 -9
- package/scripts/inject-core.ts +48 -17
- package/versions.json +4 -1
package/bin/obsidian-inject.js
CHANGED
package/package.json
CHANGED
package/scripts/help.ts
CHANGED
|
@@ -40,15 +40,14 @@ HELP:
|
|
|
40
40
|
|
|
41
41
|
π¦ EXPORTS SYSTEM
|
|
42
42
|
|
|
43
|
-
The package exposes
|
|
44
|
-
obsidian-plugin-config # Main entry
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
yarn update-exports # Regenerates package.json exports field
|
|
43
|
+
The package exposes a single entry point:
|
|
44
|
+
obsidian-plugin-config # Main entry β re-exports all modules
|
|
45
|
+
|
|
46
|
+
Src modules (auto-exported via src/index.ts):
|
|
47
|
+
modals, tools, utils
|
|
48
|
+
|
|
49
|
+
After adding a new module to src/, run:
|
|
50
|
+
yarn update-exports # Regenerates src/index.ts
|
|
52
51
|
|
|
53
52
|
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
54
53
|
|
package/scripts/inject-core.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
6
7
|
import { isValidPath, gitExec } from "./utils.js";
|
|
7
8
|
|
|
8
9
|
export interface InjectionPlan {
|
|
@@ -59,7 +60,7 @@ export async function analyzePlugin(pluginPath: string): Promise<InjectionPlan>
|
|
|
59
60
|
* Find plugin-config root directory (handles NPM global installs)
|
|
60
61
|
*/
|
|
61
62
|
export function findPluginConfigRoot(): string {
|
|
62
|
-
const scriptDir = path.dirname(
|
|
63
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
63
64
|
const npmPackageRoot = path.resolve(scriptDir, "..");
|
|
64
65
|
const npmPackageJson = path.join(npmPackageRoot, "package.json");
|
|
65
66
|
|
|
@@ -96,36 +97,66 @@ export function copyFromLocal(filePath: string): string {
|
|
|
96
97
|
*/
|
|
97
98
|
export async function ensurePluginConfigClean(): Promise<void> {
|
|
98
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
|
+
|
|
99
112
|
const originalCwd = process.cwd();
|
|
100
113
|
|
|
101
114
|
try {
|
|
102
115
|
process.chdir(configRoot);
|
|
103
|
-
const gitStatus = execSync(
|
|
116
|
+
const gitStatus = execSync(
|
|
117
|
+
"git status --porcelain",
|
|
118
|
+
{ encoding: "utf8" }
|
|
119
|
+
).trim();
|
|
104
120
|
|
|
105
121
|
if (gitStatus) {
|
|
106
|
-
console.log(
|
|
122
|
+
console.log(
|
|
123
|
+
`\nβ οΈ Plugin-config has uncommitted changes:`
|
|
124
|
+
);
|
|
107
125
|
console.log(gitStatus);
|
|
108
|
-
console.log(
|
|
126
|
+
console.log(
|
|
127
|
+
`\nπ§ Auto-committing changes...`
|
|
128
|
+
);
|
|
109
129
|
|
|
110
|
-
const
|
|
130
|
+
const msg =
|
|
131
|
+
"π§ Update plugin-config templates";
|
|
111
132
|
gitExec("git add -A");
|
|
112
|
-
gitExec(`git commit -m "${
|
|
133
|
+
gitExec(`git commit -m "${msg}"`);
|
|
113
134
|
|
|
114
135
|
try {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
);
|
|
120
144
|
} catch {
|
|
121
145
|
try {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
);
|
|
127
156
|
} catch {
|
|
128
|
-
console.log(
|
|
157
|
+
console.log(
|
|
158
|
+
`β οΈ Committed locally, push failed`
|
|
159
|
+
);
|
|
129
160
|
}
|
|
130
161
|
}
|
|
131
162
|
} else {
|