obsidian-plugin-config 1.1.11 → 1.1.12
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 +39 -39
- package/package.json +1 -1
- package/scripts/build-npm.ts +63 -51
- package/scripts/help.ts +14 -9
- package/versions.json +2 -1
package/bin/obsidian-inject.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Obsidian Plugin Config - CLI Entry Point
|
|
5
5
|
* Global command: obsidian-inject
|
|
6
|
-
* Version: 1.1.
|
|
6
|
+
* Version: 1.1.12
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { execSync } from 'child_process';
|
|
@@ -22,30 +22,30 @@ const injectScriptPath = join(packageRoot, 'scripts', 'inject-path.ts');
|
|
|
22
22
|
function showHelp() {
|
|
23
23
|
console.log(`
|
|
24
24
|
Obsidian Plugin Config - Global CLI
|
|
25
|
-
|
|
25
|
+
Injection system for autonomous Obsidian plugins
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
obsidian-inject #
|
|
29
|
-
obsidian-inject <
|
|
30
|
-
obsidian-inject --help, -h #
|
|
27
|
+
USAGE:
|
|
28
|
+
obsidian-inject # Inject in current directory
|
|
29
|
+
obsidian-inject <path> # Inject by path
|
|
30
|
+
obsidian-inject --help, -h # Show this help
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
cd
|
|
34
|
-
obsidian-inject ../
|
|
35
|
-
obsidian-inject "C:\\Users\\dev\\plugins\\
|
|
32
|
+
EXAMPLES:
|
|
33
|
+
cd my-plugin && obsidian-inject
|
|
34
|
+
obsidian-inject ../my-other-plugin
|
|
35
|
+
obsidian-inject "C:\\Users\\dev\\plugins\\my-plugin"
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
✅
|
|
39
|
-
✅
|
|
40
|
-
✅
|
|
41
|
-
✅
|
|
37
|
+
WHAT IS INJECTED:
|
|
38
|
+
✅ Local scripts (esbuild.config.ts, acp.ts, utils.ts, etc.)
|
|
39
|
+
✅ Package.json configuration (scripts, dependencies)
|
|
40
|
+
✅ Yarn protection enforced
|
|
41
|
+
✅ Automatic dependency installation
|
|
42
42
|
|
|
43
43
|
ARCHITECTURE:
|
|
44
|
-
- Plugin
|
|
45
|
-
-
|
|
46
|
-
-
|
|
44
|
+
- Plugin becomes AUTONOMOUS with local scripts
|
|
45
|
+
- No external dependencies required after injection
|
|
46
|
+
- Updates possible via re-injection
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
More info: https://github.com/3C0D/obsidian-plugin-config
|
|
49
49
|
`);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -60,8 +60,8 @@ function main() {
|
|
|
60
60
|
|
|
61
61
|
// Check if injection script exists
|
|
62
62
|
if (!fs.existsSync(injectScriptPath)) {
|
|
63
|
-
console.error(`❌
|
|
64
|
-
console.error(`
|
|
63
|
+
console.error(`❌ Error: Injection script not found at ${injectScriptPath}`);
|
|
64
|
+
console.error(` Make sure obsidian-plugin-config is properly installed.`);
|
|
65
65
|
process.exit(1);
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -74,41 +74,41 @@ function main() {
|
|
|
74
74
|
targetPath = resolve(userCwd, args[0]);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
console.log(`🎯 Obsidian Plugin Config - Injection
|
|
78
|
-
console.log(`📁
|
|
79
|
-
console.log(`📦
|
|
77
|
+
console.log(`🎯 Obsidian Plugin Config - Global Injection`);
|
|
78
|
+
console.log(`📁 Target: ${targetPath}`);
|
|
79
|
+
console.log(`📦 From: ${packageRoot}\n`);
|
|
80
80
|
|
|
81
81
|
try {
|
|
82
82
|
// Check if target directory has package.json
|
|
83
83
|
const targetPackageJson = join(targetPath, 'package.json');
|
|
84
84
|
if (!fs.existsSync(targetPackageJson)) {
|
|
85
|
-
console.error(`❌
|
|
86
|
-
console.error(`
|
|
85
|
+
console.error(`❌ Error: package.json not found in ${targetPath}`);
|
|
86
|
+
console.error(` Make sure this is a valid Node.js project.`);
|
|
87
87
|
process.exit(1);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// Clean NPM artifacts if package-lock.json exists
|
|
91
91
|
const packageLockPath = join(targetPath, 'package-lock.json');
|
|
92
92
|
if (fs.existsSync(packageLockPath)) {
|
|
93
|
-
console.log(`🧹
|
|
93
|
+
console.log(`🧹 NPM installation detected, cleaning...`);
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
96
|
// Remove package-lock.json
|
|
97
97
|
fs.unlinkSync(packageLockPath);
|
|
98
|
-
console.log(` 🗑️ package-lock.json
|
|
98
|
+
console.log(` 🗑️ package-lock.json removed`);
|
|
99
99
|
|
|
100
100
|
// Remove node_modules if it exists
|
|
101
101
|
const nodeModulesPath = join(targetPath, 'node_modules');
|
|
102
102
|
if (fs.existsSync(nodeModulesPath)) {
|
|
103
103
|
fs.rmSync(nodeModulesPath, { recursive: true, force: true });
|
|
104
|
-
console.log(` 🗑️ node_modules
|
|
104
|
+
console.log(` 🗑️ node_modules removed (will be reinstalled with Yarn)`);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
console.log(` ✅
|
|
107
|
+
console.log(` ✅ NPM artifacts cleaned to avoid Yarn conflicts`);
|
|
108
108
|
|
|
109
109
|
} catch (cleanError) {
|
|
110
|
-
console.error(` ❌
|
|
111
|
-
console.log(` 💡
|
|
110
|
+
console.error(` ❌ Cleanup failed:`, cleanError.message);
|
|
111
|
+
console.log(` 💡 Manually remove package-lock.json and node_modules`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -119,9 +119,9 @@ function main() {
|
|
|
119
119
|
cwd: targetPath,
|
|
120
120
|
stdio: 'pipe'
|
|
121
121
|
});
|
|
122
|
-
console.log(`✅ tsx
|
|
122
|
+
console.log(`✅ tsx available locally`);
|
|
123
123
|
} catch {
|
|
124
|
-
console.log(`⚠️ tsx
|
|
124
|
+
console.log(`⚠️ tsx not found, installing...`);
|
|
125
125
|
|
|
126
126
|
// Install tsx locally in target directory
|
|
127
127
|
try {
|
|
@@ -129,10 +129,10 @@ function main() {
|
|
|
129
129
|
cwd: targetPath,
|
|
130
130
|
stdio: 'inherit'
|
|
131
131
|
});
|
|
132
|
-
console.log(`✅ tsx
|
|
132
|
+
console.log(`✅ tsx installed successfully`);
|
|
133
133
|
} catch (installError) {
|
|
134
|
-
console.error(`❌
|
|
135
|
-
console.error(`
|
|
134
|
+
console.error(`❌ tsx installation failed:`, installError.message);
|
|
135
|
+
console.error(` Try installing tsx manually: cd "${targetPath}" && yarn add -D tsx`);
|
|
136
136
|
process.exit(1);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -145,10 +145,10 @@ function main() {
|
|
|
145
145
|
cwd: targetPath // Use target directory to ensure tsx is available
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
console.log(`\n✅ Injection
|
|
148
|
+
console.log(`\n✅ Injection completed successfully!`);
|
|
149
149
|
|
|
150
150
|
} catch (error) {
|
|
151
|
-
console.error(`\n❌
|
|
151
|
+
console.error(`\n❌ Injection error:`, error.message);
|
|
152
152
|
process.exit(1);
|
|
153
153
|
}
|
|
154
154
|
}
|
package/package.json
CHANGED
package/scripts/build-npm.ts
CHANGED
|
@@ -46,30 +46,30 @@ const injectScriptPath = join(packageRoot, 'scripts', 'inject-path.ts');
|
|
|
46
46
|
function showHelp() {
|
|
47
47
|
console.log(\`
|
|
48
48
|
Obsidian Plugin Config - Global CLI
|
|
49
|
-
|
|
49
|
+
Injection system for autonomous Obsidian plugins
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
obsidian-inject #
|
|
53
|
-
obsidian-inject <
|
|
54
|
-
obsidian-inject --help, -h #
|
|
51
|
+
USAGE:
|
|
52
|
+
obsidian-inject # Inject in current directory
|
|
53
|
+
obsidian-inject <path> # Inject by path
|
|
54
|
+
obsidian-inject --help, -h # Show this help
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
cd
|
|
58
|
-
obsidian-inject ../
|
|
59
|
-
obsidian-inject "C:\\\\Users\\\\dev\\\\plugins\\\\
|
|
56
|
+
EXAMPLES:
|
|
57
|
+
cd my-plugin && obsidian-inject
|
|
58
|
+
obsidian-inject ../my-other-plugin
|
|
59
|
+
obsidian-inject "C:\\\\Users\\\\dev\\\\plugins\\\\my-plugin"
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
✅
|
|
63
|
-
✅
|
|
64
|
-
✅
|
|
65
|
-
✅
|
|
61
|
+
WHAT IS INJECTED:
|
|
62
|
+
✅ Local scripts (esbuild.config.ts, acp.ts, utils.ts, etc.)
|
|
63
|
+
✅ Package.json configuration (scripts, dependencies)
|
|
64
|
+
✅ Yarn protection enforced
|
|
65
|
+
✅ Automatic dependency installation
|
|
66
66
|
|
|
67
67
|
ARCHITECTURE:
|
|
68
|
-
- Plugin
|
|
69
|
-
-
|
|
70
|
-
-
|
|
68
|
+
- Plugin becomes AUTONOMOUS with local scripts
|
|
69
|
+
- No external dependencies required after injection
|
|
70
|
+
- Updates possible via re-injection
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
More info: https://github.com/3C0D/obsidian-plugin-config
|
|
73
73
|
\`);
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -84,8 +84,8 @@ function main() {
|
|
|
84
84
|
|
|
85
85
|
// Check if injection script exists
|
|
86
86
|
if (!fs.existsSync(injectScriptPath)) {
|
|
87
|
-
console.error(\`❌
|
|
88
|
-
console.error(\`
|
|
87
|
+
console.error(\`❌ Error: Injection script not found at \${injectScriptPath}\`);
|
|
88
|
+
console.error(\` Make sure obsidian-plugin-config is properly installed.\`);
|
|
89
89
|
process.exit(1);
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -98,41 +98,41 @@ function main() {
|
|
|
98
98
|
targetPath = resolve(userCwd, args[0]);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
console.log(\`🎯 Obsidian Plugin Config - Injection
|
|
102
|
-
console.log(\`📁
|
|
103
|
-
console.log(\`📦
|
|
101
|
+
console.log(\`🎯 Obsidian Plugin Config - Global Injection\`);
|
|
102
|
+
console.log(\`📁 Target: \${targetPath}\`);
|
|
103
|
+
console.log(\`📦 From: \${packageRoot}\\n\`);
|
|
104
104
|
|
|
105
105
|
try {
|
|
106
106
|
// Check if target directory has package.json
|
|
107
107
|
const targetPackageJson = join(targetPath, 'package.json');
|
|
108
108
|
if (!fs.existsSync(targetPackageJson)) {
|
|
109
|
-
console.error(\`❌
|
|
110
|
-
console.error(\`
|
|
109
|
+
console.error(\`❌ Error: package.json not found in \${targetPath}\`);
|
|
110
|
+
console.error(\` Make sure this is a valid Node.js project.\`);
|
|
111
111
|
process.exit(1);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// Clean NPM artifacts if package-lock.json exists
|
|
115
115
|
const packageLockPath = join(targetPath, 'package-lock.json');
|
|
116
116
|
if (fs.existsSync(packageLockPath)) {
|
|
117
|
-
console.log(\`🧹
|
|
117
|
+
console.log(\`🧹 NPM installation detected, cleaning...\`);
|
|
118
118
|
|
|
119
119
|
try {
|
|
120
120
|
// Remove package-lock.json
|
|
121
121
|
fs.unlinkSync(packageLockPath);
|
|
122
|
-
console.log(\` 🗑️ package-lock.json
|
|
122
|
+
console.log(\` 🗑️ package-lock.json removed\`);
|
|
123
123
|
|
|
124
124
|
// Remove node_modules if it exists
|
|
125
125
|
const nodeModulesPath = join(targetPath, 'node_modules');
|
|
126
126
|
if (fs.existsSync(nodeModulesPath)) {
|
|
127
127
|
fs.rmSync(nodeModulesPath, { recursive: true, force: true });
|
|
128
|
-
console.log(\` 🗑️ node_modules
|
|
128
|
+
console.log(\` 🗑️ node_modules removed (will be reinstalled with Yarn)\`);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
console.log(\` ✅
|
|
131
|
+
console.log(\` ✅ NPM artifacts cleaned to avoid Yarn conflicts\`);
|
|
132
132
|
|
|
133
133
|
} catch (cleanError) {
|
|
134
|
-
console.error(\` ❌
|
|
135
|
-
console.log(\` 💡
|
|
134
|
+
console.error(\` ❌ Cleanup failed:\`, cleanError.message);
|
|
135
|
+
console.log(\` 💡 Manually remove package-lock.json and node_modules\`);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -143,9 +143,9 @@ function main() {
|
|
|
143
143
|
cwd: targetPath,
|
|
144
144
|
stdio: 'pipe'
|
|
145
145
|
});
|
|
146
|
-
console.log(\`✅ tsx
|
|
146
|
+
console.log(\`✅ tsx available locally\`);
|
|
147
147
|
} catch {
|
|
148
|
-
console.log(\`⚠️ tsx
|
|
148
|
+
console.log(\`⚠️ tsx not found, installing...\`);
|
|
149
149
|
|
|
150
150
|
// Install tsx locally in target directory
|
|
151
151
|
try {
|
|
@@ -153,10 +153,10 @@ function main() {
|
|
|
153
153
|
cwd: targetPath,
|
|
154
154
|
stdio: 'inherit'
|
|
155
155
|
});
|
|
156
|
-
console.log(\`✅ tsx
|
|
156
|
+
console.log(\`✅ tsx installed successfully\`);
|
|
157
157
|
} catch (installError) {
|
|
158
|
-
console.error(\`❌
|
|
159
|
-
console.error(\`
|
|
158
|
+
console.error(\`❌ tsx installation failed:\`, installError.message);
|
|
159
|
+
console.error(\` Try installing tsx manually: cd "\${targetPath}" && yarn add -D tsx\`);
|
|
160
160
|
process.exit(1);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
@@ -169,10 +169,10 @@ function main() {
|
|
|
169
169
|
cwd: targetPath // Use target directory to ensure tsx is available
|
|
170
170
|
});
|
|
171
171
|
|
|
172
|
-
console.log(\`\\n✅ Injection
|
|
172
|
+
console.log(\`\\n✅ Injection completed successfully!\`);
|
|
173
173
|
|
|
174
174
|
} catch (error) {
|
|
175
|
-
console.error(\`\\n❌
|
|
175
|
+
console.error(\`\\n❌ Injection error:\`, error.message);
|
|
176
176
|
process.exit(1);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
@@ -186,36 +186,48 @@ main();
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
189
|
-
*
|
|
189
|
+
* Complete NPM workflow - Version, Commit, Push, Publish
|
|
190
190
|
*/
|
|
191
191
|
function buildAndPublishNpm(): void {
|
|
192
|
-
console.log(`🚀 Obsidian Plugin Config - NPM
|
|
193
|
-
console.log(`
|
|
192
|
+
console.log(`🚀 Obsidian Plugin Config - Complete NPM Workflow`);
|
|
193
|
+
console.log(`Full automation: version → commit → push → exports → bin → publish\n`);
|
|
194
194
|
|
|
195
195
|
try {
|
|
196
|
-
// Step 1: Update
|
|
197
|
-
console.log(
|
|
196
|
+
// Step 1: Update version and push to GitHub
|
|
197
|
+
console.log(`📋 Step 1/6: Updating version...`);
|
|
198
|
+
execSync('echo 1 | tsx scripts/update-version-config.ts', { stdio: 'inherit' });
|
|
199
|
+
|
|
200
|
+
// Step 2: Commit and push any remaining changes
|
|
201
|
+
console.log(`\n📤 Step 2/6: Committing and pushing changes...`);
|
|
202
|
+
try {
|
|
203
|
+
execSync('echo "Prepare NPM package publication" | tsx scripts/acp.ts -b', { stdio: 'inherit' });
|
|
204
|
+
} catch (acpError) {
|
|
205
|
+
console.log(` ℹ️ No additional changes to commit`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Step 3: Update exports automatically
|
|
209
|
+
console.log(`\n📦 Step 3/6: Updating exports...`);
|
|
198
210
|
execSync('yarn update-exports', { stdio: 'inherit' });
|
|
199
211
|
|
|
200
|
-
// Step
|
|
201
|
-
console.log(`\n🔧 Step
|
|
212
|
+
// Step 4: Generate bin file
|
|
213
|
+
console.log(`\n🔧 Step 4/6: Generating bin/obsidian-inject.js...`);
|
|
202
214
|
generateBinFile();
|
|
203
215
|
|
|
204
|
-
// Step
|
|
205
|
-
console.log(`\n📋 Step
|
|
216
|
+
// Step 5: Verify package is ready
|
|
217
|
+
console.log(`\n📋 Step 5/6: Verifying package...`);
|
|
206
218
|
verifyPackage();
|
|
207
219
|
|
|
208
|
-
// Step
|
|
209
|
-
console.log(`\n📤 Step
|
|
220
|
+
// Step 6: Publish to NPM
|
|
221
|
+
console.log(`\n📤 Step 6/6: Publishing to NPM...`);
|
|
210
222
|
execSync('npm publish --registry https://registry.npmjs.org/', { stdio: 'inherit' });
|
|
211
223
|
|
|
212
|
-
console.log(`\n🎉
|
|
224
|
+
console.log(`\n🎉 Complete workflow successful!`);
|
|
213
225
|
console.log(`\n📋 Next steps:`);
|
|
214
226
|
console.log(` 1. npm install -g obsidian-plugin-config`);
|
|
215
227
|
console.log(` 2. Test injection: cd any-plugin && obsidian-inject`);
|
|
216
228
|
|
|
217
229
|
} catch (error) {
|
|
218
|
-
console.error(`\n❌
|
|
230
|
+
console.error(`\n❌ Workflow failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
219
231
|
process.exit(1);
|
|
220
232
|
}
|
|
221
233
|
}
|
package/scripts/help.ts
CHANGED
|
@@ -48,23 +48,28 @@ Usage:
|
|
|
48
48
|
|
|
49
49
|
═══════════════════════════════════════════════════════════════════
|
|
50
50
|
|
|
51
|
-
🚀 COMPLETE
|
|
51
|
+
🚀 COMPLETE WORKFLOWS
|
|
52
52
|
|
|
53
|
+
DEVELOPMENT WORKFLOW (Manual control):
|
|
53
54
|
1. Make changes to obsidian-plugin-config
|
|
54
55
|
2. yarn lint:fix # Fix any linting issues
|
|
55
|
-
3. yarn v # Update version
|
|
56
|
-
4. yarn bacp # Commit
|
|
57
|
-
5. yarn npm-publish # Complete NPM workflow
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
3. yarn v # Update version + commit + push GitHub
|
|
57
|
+
4. yarn bacp # Commit other changes + push GitHub
|
|
58
|
+
5. yarn npm-publish # Complete NPM workflow
|
|
59
|
+
|
|
60
|
+
AUTOMATED WORKFLOW (One command):
|
|
61
|
+
yarn npm-publish # Does EVERYTHING automatically:
|
|
62
|
+
# → Update version (patch)
|
|
63
|
+
# → Commit and push to GitHub
|
|
63
64
|
# → Update exports
|
|
64
65
|
# → Generate bin/obsidian-inject.js
|
|
65
66
|
# → Verify package
|
|
66
67
|
# → Publish to NPM
|
|
67
68
|
|
|
69
|
+
AFTER NPM PUBLISH:
|
|
70
|
+
npm install -g obsidian-plugin-config # Update global package
|
|
71
|
+
Test injection: cd any-plugin && obsidian-inject
|
|
72
|
+
|
|
68
73
|
═══════════════════════════════════════════════════════════════════
|
|
69
74
|
|
|
70
75
|
`);
|