obsidian-plugin-config 1.6.0 → 1.6.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/.vscode/tasks.json +2 -9
- package/bin/obsidian-inject.js +1 -1
- package/package.json +1 -1
- package/scripts/acp.ts +1 -10
- package/scripts/build-npm.ts +33 -29
- package/scripts/inject-core.ts +28 -6
package/.vscode/tasks.json
CHANGED
|
@@ -44,19 +44,12 @@
|
|
|
44
44
|
{
|
|
45
45
|
"label": "NPM Publish",
|
|
46
46
|
"type": "shell",
|
|
47
|
-
"command": "yarn npm-publish
|
|
47
|
+
"command": "yarn npm-publish",
|
|
48
48
|
"group": { "kind": "build", "isDefault": true },
|
|
49
49
|
"presentation": { "reveal": "always", "panel": "shared" },
|
|
50
50
|
"problemMatcher": []
|
|
51
51
|
},
|
|
52
|
-
|
|
53
|
-
"label": "Install/Update obsidian-inject",
|
|
54
|
-
"type": "shell",
|
|
55
|
-
"command": "npm list -g obsidian-plugin-config --depth=0 && npm install -g obsidian-plugin-config@latest --force --engine-strict=false && npm list -g obsidian-plugin-config --depth=0",
|
|
56
|
-
"group": "build",
|
|
57
|
-
"presentation": { "reveal": "always", "panel": "shared" },
|
|
58
|
-
"problemMatcher": []
|
|
59
|
-
},
|
|
52
|
+
|
|
60
53
|
{
|
|
61
54
|
"label": "Cleanup: Lint + Prettier",
|
|
62
55
|
"dependsOrder": "sequence",
|
package/bin/obsidian-inject.js
CHANGED
package/package.json
CHANGED
package/scripts/acp.ts
CHANGED
|
@@ -33,16 +33,7 @@ async function main(): Promise<void> {
|
|
|
33
33
|
console.log('Build successful.');
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
!process.argv.includes('-ne') &&
|
|
39
|
-
!process.argv.includes('--no-exports') &&
|
|
40
|
-
isInCentralizedRepo()
|
|
41
|
-
) {
|
|
42
|
-
console.log('Updating exports...');
|
|
43
|
-
gitExec('yarn run update-exports');
|
|
44
|
-
console.log('Exports updated.');
|
|
45
|
-
}
|
|
36
|
+
|
|
46
37
|
|
|
47
38
|
const input: string = await askQuestion('Enter commit message: ', rl);
|
|
48
39
|
|
package/scripts/build-npm.ts
CHANGED
|
@@ -223,7 +223,7 @@ async function ensureNpmAuth(): Promise<void> {
|
|
|
223
223
|
stdio: 'inherit'
|
|
224
224
|
});
|
|
225
225
|
console.log(`\n ✅ Successfully logged in to NPM\n`);
|
|
226
|
-
} catch
|
|
226
|
+
} catch {
|
|
227
227
|
console.error(`\n ❌ NPM login failed`);
|
|
228
228
|
console.error(` Please run 'npm login' manually and try again`);
|
|
229
229
|
throw new Error('NPM authentication required');
|
|
@@ -257,11 +257,29 @@ async function buildAndPublishNpm(): Promise<void> {
|
|
|
257
257
|
// Step 4: Commit and push
|
|
258
258
|
console.log(`\n📤 Step 4/5: Committing and pushing changes...`);
|
|
259
259
|
try {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
// Add all changes
|
|
261
|
+
execSync('git add -A', { stdio: 'pipe' });
|
|
262
|
+
|
|
263
|
+
// Check if there are changes to commit
|
|
264
|
+
const status = execSync('git status --porcelain', { encoding: 'utf8' });
|
|
265
|
+
if (status.trim()) {
|
|
266
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
267
|
+
execSync(`git commit -m "Publish NPM package v${packageJson.version}"`, {
|
|
268
|
+
stdio: 'pipe'
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// Get current branch and push
|
|
272
|
+
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
273
|
+
encoding: 'utf8'
|
|
274
|
+
}).trim();
|
|
275
|
+
execSync(`git push origin ${currentBranch}`, { stdio: 'inherit' });
|
|
276
|
+
console.log(` ✅ Changes committed and pushed`);
|
|
277
|
+
} else {
|
|
278
|
+
console.log(` ℹ️ No changes to commit`);
|
|
279
|
+
}
|
|
280
|
+
} catch (error) {
|
|
281
|
+
console.error(` ❌ Commit/push failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
282
|
+
throw error;
|
|
265
283
|
}
|
|
266
284
|
|
|
267
285
|
// Step 5: Publish to NPM
|
|
@@ -270,29 +288,15 @@ async function buildAndPublishNpm(): Promise<void> {
|
|
|
270
288
|
stdio: 'inherit'
|
|
271
289
|
});
|
|
272
290
|
|
|
273
|
-
// Optional: Update global CLI
|
|
274
|
-
console.log(`\n🌍
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
`Install obsidian-plugin-config@latest globally?`,
|
|
283
|
-
rl
|
|
284
|
-
);
|
|
285
|
-
rl.close();
|
|
286
|
-
}
|
|
287
|
-
if (doUpdate) {
|
|
288
|
-
console.log(` ⏳ Waiting 15s for NPM registry propagation...`);
|
|
289
|
-
await new Promise((resolve) => setTimeout(resolve, 15000));
|
|
290
|
-
execSync(
|
|
291
|
-
'npm install -g obsidian-plugin-config@latest --force --engine-strict=false',
|
|
292
|
-
{ stdio: 'inherit' }
|
|
293
|
-
);
|
|
294
|
-
console.log(` ✅ Global CLI updated`);
|
|
295
|
-
}
|
|
291
|
+
// Optional: Update global CLI automatically
|
|
292
|
+
console.log(`\n🌍 Updating global CLI...`);
|
|
293
|
+
console.log(` ⏳ Waiting 15s for NPM registry propagation...`);
|
|
294
|
+
await new Promise((resolve) => setTimeout(resolve, 15000));
|
|
295
|
+
execSync(
|
|
296
|
+
'npm install -g obsidian-plugin-config@latest --force --engine-strict=false',
|
|
297
|
+
{ stdio: 'inherit' }
|
|
298
|
+
);
|
|
299
|
+
console.log(` ✅ Global CLI updated`);
|
|
296
300
|
|
|
297
301
|
console.log(`\n🎉 Complete workflow successful!`);
|
|
298
302
|
console.log(` Test: cd any-plugin && obsidian-inject`);
|
package/scripts/inject-core.ts
CHANGED
|
@@ -670,15 +670,37 @@ export async function cleanNpmArtifactsIfNeeded(targetPath: string): Promise<voi
|
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
if (fs.existsSync(nodeModulesPath)) {
|
|
673
|
+
console.log(` ⏳ Removing node_modules (this may take a moment)...`);
|
|
673
674
|
try {
|
|
674
|
-
|
|
675
|
+
// Try standard rmdir first
|
|
676
|
+
execSync(`rmdir /s /q "${nodeModulesPath}"`, {
|
|
677
|
+
stdio: 'pipe',
|
|
678
|
+
windowsHide: true
|
|
679
|
+
});
|
|
680
|
+
console.log(
|
|
681
|
+
` 🗑️ Removed node_modules (will be reinstalled with Yarn)`
|
|
682
|
+
);
|
|
675
683
|
} catch {
|
|
676
|
-
//
|
|
677
|
-
|
|
684
|
+
// If locked, rename it and let yarn install create a fresh one
|
|
685
|
+
try {
|
|
686
|
+
const timestamp = Date.now();
|
|
687
|
+
const oldPath = `${nodeModulesPath}.old.${timestamp}`;
|
|
688
|
+
fs.renameSync(nodeModulesPath, oldPath);
|
|
689
|
+
console.log(
|
|
690
|
+
` 🔄 Renamed locked node_modules to ${path.basename(oldPath)}`
|
|
691
|
+
);
|
|
692
|
+
console.log(
|
|
693
|
+
` 💡 You can delete it manually later when processes are closed`
|
|
694
|
+
);
|
|
695
|
+
} catch {
|
|
696
|
+
console.log(
|
|
697
|
+
` ⚠️ Could not remove node_modules (files locked by running processes)`
|
|
698
|
+
);
|
|
699
|
+
console.log(
|
|
700
|
+
` 💡 Yarn will update it anyway, but close processes for clean install`
|
|
701
|
+
);
|
|
702
|
+
}
|
|
678
703
|
}
|
|
679
|
-
console.log(
|
|
680
|
-
` 🗑️ Removed node_modules (will be reinstalled with Yarn)`
|
|
681
|
-
);
|
|
682
704
|
}
|
|
683
705
|
|
|
684
706
|
console.log(` ✅ Lock files and artifacts cleaned for fresh install`);
|