obsidian-plugin-config 1.6.18 ā 1.7.0
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/.editorconfig +9 -14
- package/.prettierrc +3 -12
- package/bin/obsidian-inject.js +1 -1
- package/docs/INTERACTIVE_INJECTION.md +4 -4
- package/docs/LLM-GUIDE.md +12 -2
- package/eslint.config.mts +63 -64
- package/package.json +3 -3
- package/scripts/acp.ts +52 -56
- package/scripts/build-npm.ts +161 -157
- package/scripts/inject-core.ts +835 -823
- package/scripts/inject-path.ts +150 -160
- package/scripts/inject-prompt.ts +89 -91
- package/scripts/update-version-config.ts +121 -89
- package/scripts/utils.ts +112 -112
- package/templates/.editorconfig +11 -14
- package/templates/.prettierrc +3 -12
- package/templates/env.template +12 -9
- package/templates/eslint.config.mts +1 -1
- package/templates/package.json +2 -3
- package/templates/scripts/acp.ts +50 -74
- package/templates/scripts/constants.ts +26 -0
- package/templates/scripts/env.ts +94 -0
- package/templates/scripts/esbuild.config.ts +134 -287
- package/templates/scripts/release.ts +92 -87
- package/templates/scripts/reload.ts +46 -0
- package/templates/scripts/typingsPlugin.ts +26 -0
- package/templates/scripts/update-version.ts +120 -123
- package/templates/scripts/utils.ts +234 -134
- package/templates/tsconfig.json +2 -2
- package/tsconfig.json +1 -1
package/scripts/build-npm.ts
CHANGED
|
@@ -8,21 +8,21 @@ import { execSync } from 'child_process';
|
|
|
8
8
|
* Generate bin/obsidian-inject.js from template
|
|
9
9
|
*/
|
|
10
10
|
async function generateBinFile(): Promise<void> {
|
|
11
|
-
|
|
11
|
+
console.log(`\nš§ Generating bin/obsidian-inject.js...`);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const binDir = 'bin';
|
|
14
|
+
const binPath = path.join(binDir, 'obsidian-inject.js');
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
// Ensure bin directory exists
|
|
17
|
+
if (!fs.existsSync(binDir)) {
|
|
18
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
19
|
+
console.log(` š Created ${binDir} directory`);
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Read package.json for version info
|
|
23
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const binContent = `#!/usr/bin/env node
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Obsidian Plugin Config - CLI Entry Point
|
|
@@ -210,170 +210,174 @@ function main() {
|
|
|
210
210
|
main();
|
|
211
211
|
`;
|
|
212
212
|
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
fs.writeFileSync(binPath, binContent, 'utf8');
|
|
214
|
+
console.log(` ā
Generated ${binPath}`);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
218
|
* Check NPM authentication and prompt login if needed
|
|
219
219
|
*/
|
|
220
220
|
async function ensureNpmAuth(): Promise<void> {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
221
|
+
console.log(`š Checking NPM authentication...`);
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
const whoami = execSync('npm whoami --registry https://registry.npmjs.org/', {
|
|
225
|
+
stdio: 'pipe',
|
|
226
|
+
encoding: 'utf8'
|
|
227
|
+
}).trim();
|
|
228
|
+
console.log(` ā
Logged in as: ${whoami}\n`);
|
|
229
|
+
} catch {
|
|
230
|
+
console.log(` ā ļø Not logged in to NPM\n`);
|
|
231
|
+
console.log(`š Please login to NPM to publish the package`);
|
|
232
|
+
console.log(` Opening browser for authentication...\n`);
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
execSync('npm login --auth-type=web --registry https://registry.npmjs.org/', {
|
|
236
|
+
stdio: 'inherit'
|
|
237
|
+
});
|
|
238
|
+
console.log(`\n ā
Successfully logged in to NPM\n`);
|
|
239
|
+
} catch {
|
|
240
|
+
console.error(`\n ā NPM login failed`);
|
|
241
|
+
console.error(` Please run 'npm login' manually and try again`);
|
|
242
|
+
throw new Error('NPM authentication required');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
248
|
* Complete NPM workflow - Version, Commit, Push, Publish
|
|
249
249
|
*/
|
|
250
250
|
async function buildAndPublishNpm(): Promise<void> {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
251
|
+
console.log(`š Obsidian Plugin Config - NPM Publish Workflow`);
|
|
252
|
+
console.log(`Automation: version ā bin ā verify ā commit ā publish\n`);
|
|
253
|
+
|
|
254
|
+
try {
|
|
255
|
+
// Step 0: Check NPM authentication
|
|
256
|
+
await ensureNpmAuth();
|
|
257
|
+
|
|
258
|
+
// Step 1: Update version
|
|
259
|
+
console.log(`š Step 1/5: Updating version...`);
|
|
260
|
+
execSync('tsx scripts/update-version-config.ts', { stdio: 'inherit' });
|
|
261
|
+
|
|
262
|
+
// Step 2: Generate bin file
|
|
263
|
+
console.log(`\nš§ Step 2/5: Generating bin/obsidian-inject.js...`);
|
|
264
|
+
await generateBinFile();
|
|
265
|
+
|
|
266
|
+
// Step 3: Verify package
|
|
267
|
+
console.log(`\nš Step 3/5: Verifying package...`);
|
|
268
|
+
verifyPackage();
|
|
269
|
+
|
|
270
|
+
// Step 4: Commit and push
|
|
271
|
+
console.log(`\nš¤ Step 4/5: Committing and pushing changes...`);
|
|
272
|
+
try {
|
|
273
|
+
// Add all changes
|
|
274
|
+
execSync('git add -A', { stdio: 'pipe' });
|
|
275
|
+
|
|
276
|
+
// Check if there are changes to commit
|
|
277
|
+
const status = execSync('git status --porcelain', { encoding: 'utf8' });
|
|
278
|
+
if (status.trim()) {
|
|
279
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
280
|
+
execSync(`git commit -m "Publish NPM package v${packageJson.version}"`, {
|
|
281
|
+
stdio: 'pipe'
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Get current branch and push
|
|
285
|
+
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
286
|
+
encoding: 'utf8'
|
|
287
|
+
}).trim();
|
|
288
|
+
execSync(`git push origin ${currentBranch}`, { stdio: 'inherit' });
|
|
289
|
+
console.log(` ā
Changes committed and pushed`);
|
|
290
|
+
} else {
|
|
291
|
+
console.log(` ā¹ļø No changes to commit`);
|
|
292
|
+
}
|
|
293
|
+
} catch (error) {
|
|
294
|
+
console.error(
|
|
295
|
+
` ā Commit/push failed: ${error instanceof Error ? error.message : String(error)}`
|
|
296
|
+
);
|
|
297
|
+
throw error;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Step 5: Publish to NPM
|
|
301
|
+
console.log(`\nš¤ Step 5/5: Publishing to NPM...`);
|
|
302
|
+
execSync('npm publish --registry https://registry.npmjs.org/', {
|
|
303
|
+
stdio: 'inherit'
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Optional: Update global CLI automatically
|
|
307
|
+
console.log(`\nš Updating global CLI...`);
|
|
308
|
+
console.log(` ā³ Waiting 30s for NPM registry propagation...`);
|
|
309
|
+
await new Promise((resolve) => setTimeout(resolve, 30000));
|
|
310
|
+
try {
|
|
311
|
+
execSync(
|
|
312
|
+
'npm install -g obsidian-plugin-config@latest --force --engine-strict=false',
|
|
313
|
+
{ stdio: 'inherit' }
|
|
314
|
+
);
|
|
315
|
+
console.log(` ā
Global CLI updated`);
|
|
316
|
+
} catch {
|
|
317
|
+
console.log(` ā ļø Global CLI update failed (NPM registry may need more time)`);
|
|
318
|
+
console.log(
|
|
319
|
+
` š” Run manually in a few minutes: npm install -g obsidian-plugin-config@latest --force`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
console.log(`\nš Complete workflow successful!`);
|
|
323
|
+
console.log(` Test: cd any-plugin && obsidian-inject`);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
console.error(
|
|
326
|
+
`\nā Workflow failed: ${error instanceof Error ? error.message : String(error)}`
|
|
327
|
+
);
|
|
328
|
+
process.exit(1);
|
|
329
|
+
}
|
|
326
330
|
}
|
|
327
331
|
|
|
328
332
|
/**
|
|
329
333
|
* Verify package is ready for publication
|
|
330
334
|
*/
|
|
331
335
|
function verifyPackage(): void {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
336
|
+
// Check required scripts
|
|
337
|
+
const requiredScripts = [
|
|
338
|
+
'scripts/inject-path.ts',
|
|
339
|
+
'scripts/inject-prompt.ts',
|
|
340
|
+
'scripts/inject-core.ts',
|
|
341
|
+
'scripts/utils.ts',
|
|
342
|
+
'scripts/acp.ts',
|
|
343
|
+
'scripts/update-version-config.ts',
|
|
344
|
+
'scripts/help.ts'
|
|
345
|
+
];
|
|
346
|
+
|
|
347
|
+
for (const script of requiredScripts) {
|
|
348
|
+
if (!fs.existsSync(script)) {
|
|
349
|
+
throw new Error(`Missing required script: ${script}`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
console.log(` ā
All required scripts present`);
|
|
353
|
+
|
|
354
|
+
// Check package.json
|
|
355
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
356
|
+
const requiredFields = [
|
|
357
|
+
'name',
|
|
358
|
+
'version',
|
|
359
|
+
'description',
|
|
360
|
+
'bin',
|
|
361
|
+
'repository',
|
|
362
|
+
'author'
|
|
363
|
+
];
|
|
364
|
+
|
|
365
|
+
for (const field of requiredFields) {
|
|
366
|
+
if (!packageJson[field]) {
|
|
367
|
+
throw new Error(`Missing required package.json field: ${field}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
console.log(` ā
Package.json valid (v${packageJson.version})`);
|
|
371
|
+
|
|
372
|
+
// Check bin file exists
|
|
373
|
+
if (!fs.existsSync('bin/obsidian-inject.js')) {
|
|
374
|
+
throw new Error(`Missing bin file: bin/obsidian-inject.js`);
|
|
375
|
+
}
|
|
376
|
+
console.log(` ā
Bin file ready`);
|
|
377
|
+
|
|
378
|
+
// Quick build test
|
|
379
|
+
execSync('tsc --noEmit', { stdio: 'pipe' });
|
|
380
|
+
console.log(` ā
TypeScript check passed`);
|
|
377
381
|
}
|
|
378
382
|
|
|
379
383
|
// Run the script
|