obsidian-plugin-config 1.7.1 → 1.7.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.
@@ -1,156 +1,156 @@
1
- #!/usr/bin/env tsx
2
-
3
- import fs from 'fs';
4
- import path from 'path';
5
- import {
6
- analyzePlugin,
7
- ensurePluginConfigClean,
8
- findPluginConfigRoot,
9
- performInjection,
10
- readInjectionInfo,
11
- showInjectionPlan
12
- } from './inject-core.js';
13
- import { isValidPath } from './utils.js';
14
-
15
- async function main(): Promise<void> {
16
- try {
17
- // Show version
18
- const configRoot = findPluginConfigRoot();
19
- let version = 'unknown';
20
- try {
21
- const pkg = JSON.parse(
22
- fs.readFileSync(path.join(configRoot, 'package.json'), 'utf8')
23
- );
24
- version = pkg.version || 'unknown';
25
- } catch {
26
- // Ignore
27
- }
28
-
29
- console.log(`🎯 Obsidian Plugin Config - Local Injection Tool v${version}`);
30
- console.log(`📥 Inject autonomous configuration from local files\n`);
31
-
32
- const args = process.argv.slice(2);
33
- const autoConfirm = args.includes('--yes') || args.includes('-y');
34
- const dryRun = args.includes('--dry-run') || args.includes('--check');
35
- const targetPath = args.find((arg) => !arg.startsWith('-'));
36
-
37
- if (!targetPath) {
38
- console.error(`❌ Usage: yarn inject-path <plugin-directory> [options]`);
39
- console.error(` Example: yarn inject-path ../my-obsidian-plugin`);
40
- console.error(` Options:`);
41
- console.error(` --yes, -y Auto-confirm injection`);
42
- console.error(` --dry-run Check only (no injection)`);
43
- console.error(` Shortcuts:`);
44
- console.error(` yarn check-plugin ../plugin # Verification only`);
45
- process.exit(1);
46
- }
47
-
48
- const resolvedPath = path.resolve(targetPath);
49
-
50
- if (!(await isValidPath(resolvedPath))) {
51
- console.error(`❌ Directory not found: ${resolvedPath}`);
52
- process.exit(1);
53
- }
54
-
55
- // Prevent injecting into obsidian-plugin-config itself
56
- const selfPkg = path.join(resolvedPath, 'package.json');
57
- if (fs.existsSync(selfPkg)) {
58
- const pkg = JSON.parse(fs.readFileSync(selfPkg, 'utf8'));
59
- if (pkg.name === 'obsidian-plugin-config') {
60
- console.error(`❌ Cannot inject into obsidian-plugin-config itself.`);
61
- process.exit(1);
62
- }
63
- }
64
-
65
- console.log(`📁 Target directory: ${resolvedPath}`);
66
- console.log(`\n🔍 Analyzing plugin...`);
67
- const plan = await analyzePlugin(resolvedPath);
68
-
69
- if (dryRun) {
70
- console.log(`\n🎯 Injection Plan for: ${plan.targetPath}`);
71
- console.log(`📁 Target: ${path.basename(plan.targetPath)}`);
72
- console.log(`📦 Package.json: ${plan.hasPackageJson ? '✅' : '❌'}`);
73
- console.log(`📋 Manifest.json: ${plan.hasManifest ? '✅' : '❌'}`);
74
- console.log(
75
- `📂 Scripts folder: ${plan.hasScriptsFolder ? '✅ (will be updated)' : '❌ (will be created)'}`
76
- );
77
- console.log(`🔌 Obsidian plugin: ${plan.isObsidianPlugin ? '✅' : '❌'}`);
78
-
79
- if (!plan.isObsidianPlugin) {
80
- console.log(`\n⚠️ Warning: This doesn't appear to be a valid Obsidian plugin`);
81
- console.log(` Missing manifest.json or invalid structure`);
82
- }
83
-
84
- console.log(`\n📋 Would inject:`);
85
- console.log(` ✅ Local scripts (utils.ts, esbuild.config.ts, acp.ts, etc.)`);
86
- console.log(` ✅ Updated package.json scripts`);
87
- console.log(` ✅ Required dependencies`);
88
-
89
- const injectionInfo = readInjectionInfo(resolvedPath);
90
-
91
- if (injectionInfo) {
92
- console.log(`\n✅ Status: Plugin is already injected`);
93
- console.log(` 📦 Injector: ${injectionInfo.injectorName || 'unknown'}`);
94
- console.log(` 🏷️ Version: ${injectionInfo.injectorVersion || 'unknown'}`);
95
- console.log(
96
- ` 📅 Date: ${
97
- injectionInfo.injectionDate
98
- ? new Date(injectionInfo.injectionDate).toLocaleDateString()
99
- : 'unknown'
100
- }`
101
- );
102
-
103
- const configRoot = findPluginConfigRoot();
104
- try {
105
- const configPackageJson = JSON.parse(
106
- fs.readFileSync(path.join(configRoot, 'package.json'), 'utf8')
107
- );
108
- const currentVersion = configPackageJson.version;
109
- if (
110
- currentVersion &&
111
- injectionInfo.injectorVersion &&
112
- currentVersion !== injectionInfo.injectorVersion
113
- ) {
114
- console.log(
115
- ` 🔄 Update available: ${injectionInfo.injectorVersion} → ${currentVersion}`
116
- );
117
- }
118
- } catch {
119
- // Ignore version comparison errors
120
- }
121
- } else {
122
- const hasInjectedScripts = fs.existsSync(
123
- path.join(resolvedPath, 'scripts', 'utils.ts')
124
- );
125
- if (hasInjectedScripts) {
126
- console.log(`\n⚠️ Status: Plugin appears to be injected (legacy)`);
127
- console.log(` Found: scripts/utils.ts but no .injection-info.json`);
128
- console.log(` 💡 Re-inject to add version tracking`);
129
- } else {
130
- console.log(`\n❌ Status: Plugin not yet injected`);
131
- }
132
- }
133
-
134
- console.log(`\n🔍 Dry-run completed - no changes made`);
135
- console.log(` To inject: yarn inject ${targetPath} --yes`);
136
- return;
137
- }
138
-
139
- console.log(`\n🔍 Checking plugin-config repository status...`);
140
- await ensurePluginConfigClean();
141
-
142
- const confirmed = await showInjectionPlan(plan, autoConfirm);
143
-
144
- if (!confirmed) {
145
- console.log(`❌ Injection cancelled by user`);
146
- process.exit(0);
147
- }
148
-
149
- await performInjection(resolvedPath, autoConfirm);
150
- } catch (error) {
151
- console.error(`💥 Error: ${error instanceof Error ? error.message : String(error)}`);
152
- process.exit(1);
153
- }
154
- }
155
-
156
- main().catch(console.error);
1
+ #!/usr/bin/env tsx
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import {
6
+ analyzePlugin,
7
+ ensurePluginConfigClean,
8
+ findPluginConfigRoot,
9
+ performInjection,
10
+ readInjectionInfo,
11
+ showInjectionPlan
12
+ } from './inject-core.js';
13
+ import { isValidPath } from './utils.js';
14
+
15
+ async function main(): Promise<void> {
16
+ try {
17
+ // Show version
18
+ const configRoot = findPluginConfigRoot();
19
+ let version = 'unknown';
20
+ try {
21
+ const pkg = JSON.parse(
22
+ fs.readFileSync(path.join(configRoot, 'package.json'), 'utf8')
23
+ );
24
+ version = pkg.version || 'unknown';
25
+ } catch {
26
+ // Ignore
27
+ }
28
+
29
+ console.log(`🎯 Obsidian Plugin Config - Local Injection Tool v${version}`);
30
+ console.log(`📥 Inject autonomous configuration from local files\n`);
31
+
32
+ const args = process.argv.slice(2);
33
+ const autoConfirm = args.includes('--yes') || args.includes('-y');
34
+ const dryRun = args.includes('--dry-run') || args.includes('--check');
35
+ const targetPath = args.find((arg) => !arg.startsWith('-'));
36
+
37
+ if (!targetPath) {
38
+ console.error(`❌ Usage: yarn inject-path <plugin-directory> [options]`);
39
+ console.error(` Example: yarn inject-path ../my-obsidian-plugin`);
40
+ console.error(` Options:`);
41
+ console.error(` --yes, -y Auto-confirm injection`);
42
+ console.error(` --dry-run Check only (no injection)`);
43
+ console.error(` Shortcuts:`);
44
+ console.error(` yarn check-plugin ../plugin # Verification only`);
45
+ process.exit(1);
46
+ }
47
+
48
+ const resolvedPath = path.resolve(targetPath);
49
+
50
+ if (!(await isValidPath(resolvedPath))) {
51
+ console.error(`❌ Directory not found: ${resolvedPath}`);
52
+ process.exit(1);
53
+ }
54
+
55
+ // Prevent injecting into obsidian-plugin-config itself
56
+ const selfPkg = path.join(resolvedPath, 'package.json');
57
+ if (fs.existsSync(selfPkg)) {
58
+ const pkg = JSON.parse(fs.readFileSync(selfPkg, 'utf8'));
59
+ if (pkg.name === 'obsidian-plugin-config') {
60
+ console.error(`❌ Cannot inject into obsidian-plugin-config itself.`);
61
+ process.exit(1);
62
+ }
63
+ }
64
+
65
+ console.log(`📁 Target directory: ${resolvedPath}`);
66
+ console.log(`\n🔍 Analyzing plugin...`);
67
+ const plan = await analyzePlugin(resolvedPath);
68
+
69
+ if (dryRun) {
70
+ console.log(`\n🎯 Injection Plan for: ${plan.targetPath}`);
71
+ console.log(`📁 Target: ${path.basename(plan.targetPath)}`);
72
+ console.log(`📦 Package.json: ${plan.hasPackageJson ? '✅' : '❌'}`);
73
+ console.log(`📋 Manifest.json: ${plan.hasManifest ? '✅' : '❌'}`);
74
+ console.log(
75
+ `📂 Scripts folder: ${plan.hasScriptsFolder ? '✅ (will be updated)' : '❌ (will be created)'}`
76
+ );
77
+ console.log(`🔌 Obsidian plugin: ${plan.isObsidianPlugin ? '✅' : '❌'}`);
78
+
79
+ if (!plan.isObsidianPlugin) {
80
+ console.log(`\n⚠️ Warning: This doesn't appear to be a valid Obsidian plugin`);
81
+ console.log(` Missing manifest.json or invalid structure`);
82
+ }
83
+
84
+ console.log(`\n📋 Would inject:`);
85
+ console.log(` ✅ Local scripts (utils.ts, esbuild.config.ts, acp.ts, etc.)`);
86
+ console.log(` ✅ Updated package.json scripts`);
87
+ console.log(` ✅ Required dependencies`);
88
+
89
+ const injectionInfo = readInjectionInfo(resolvedPath);
90
+
91
+ if (injectionInfo) {
92
+ console.log(`\n✅ Status: Plugin is already injected`);
93
+ console.log(` 📦 Injector: ${injectionInfo.injectorName || 'unknown'}`);
94
+ console.log(` 🏷️ Version: ${injectionInfo.injectorVersion || 'unknown'}`);
95
+ console.log(
96
+ ` 📅 Date: ${
97
+ injectionInfo.injectionDate
98
+ ? new Date(injectionInfo.injectionDate).toLocaleDateString()
99
+ : 'unknown'
100
+ }`
101
+ );
102
+
103
+ const configRoot = findPluginConfigRoot();
104
+ try {
105
+ const configPackageJson = JSON.parse(
106
+ fs.readFileSync(path.join(configRoot, 'package.json'), 'utf8')
107
+ );
108
+ const currentVersion = configPackageJson.version;
109
+ if (
110
+ currentVersion &&
111
+ injectionInfo.injectorVersion &&
112
+ currentVersion !== injectionInfo.injectorVersion
113
+ ) {
114
+ console.log(
115
+ ` 🔄 Update available: ${injectionInfo.injectorVersion} → ${currentVersion}`
116
+ );
117
+ }
118
+ } catch {
119
+ // Ignore version comparison errors
120
+ }
121
+ } else {
122
+ const hasInjectedScripts = fs.existsSync(
123
+ path.join(resolvedPath, 'scripts', 'utils.ts')
124
+ );
125
+ if (hasInjectedScripts) {
126
+ console.log(`\n⚠️ Status: Plugin appears to be injected (legacy)`);
127
+ console.log(` Found: scripts/utils.ts but no .injection-info.json`);
128
+ console.log(` 💡 Re-inject to add version tracking`);
129
+ } else {
130
+ console.log(`\n❌ Status: Plugin not yet injected`);
131
+ }
132
+ }
133
+
134
+ console.log(`\n🔍 Dry-run completed - no changes made`);
135
+ console.log(` To inject: yarn inject ${targetPath} --yes`);
136
+ return;
137
+ }
138
+
139
+ console.log(`\n🔍 Checking plugin-config repository status...`);
140
+ await ensurePluginConfigClean();
141
+
142
+ const confirmed = await showInjectionPlan(plan, autoConfirm);
143
+
144
+ if (!confirmed) {
145
+ console.log(`❌ Injection cancelled by user`);
146
+ process.exit(0);
147
+ }
148
+
149
+ await performInjection(resolvedPath, autoConfirm);
150
+ } catch (error) {
151
+ console.error(`💥 Error: ${error instanceof Error ? error.message : String(error)}`);
152
+ process.exit(1);
153
+ }
154
+ }
155
+
156
+ main().catch(console.error);
@@ -1,104 +1,104 @@
1
- #!/usr/bin/env tsx
2
-
3
- import fs from 'fs';
4
- import path from 'path';
5
- import {
6
- analyzePlugin,
7
- ensurePluginConfigClean,
8
- performInjection,
9
- showInjectionPlan
10
- } from './inject-core.js';
11
- import {
12
- askConfirmation,
13
- askQuestion,
14
- createReadlineInterface,
15
- isValidPath
16
- } from './utils.js';
17
-
18
- const rl = createReadlineInterface();
19
-
20
- async function promptForTargetPath(): Promise<string> {
21
- console.log(`\n📁 Select target plugin directory:`);
22
- console.log(` Common paths (copy-paste ready):`);
23
- console.log(` - ../test-sample-plugin`);
24
- console.log(` 💡 Tip: You can paste paths with or without quotes`);
25
-
26
- while (true) {
27
- const rawInput = await askQuestion(`\nEnter plugin directory path: `, rl);
28
-
29
- if (!rawInput.trim()) {
30
- console.log(`❌ Please enter a valid path`);
31
- continue;
32
- }
33
-
34
- const cleanPath = rawInput.trim().replace(/^["']|["']$/g, '');
35
- const resolvedPath = path.resolve(cleanPath);
36
-
37
- if (!(await isValidPath(resolvedPath))) {
38
- console.log(`❌ Directory not found: ${resolvedPath}`);
39
- const retry = await askConfirmation(`Try again?`, rl);
40
- if (!retry) throw new Error('User cancelled');
41
- continue;
42
- }
43
-
44
- console.log(`📁 Target directory: ${resolvedPath}`);
45
- return resolvedPath;
46
- }
47
- }
48
-
49
- async function main(): Promise<void> {
50
- try {
51
- console.log(`🎯 Obsidian Plugin Config - Interactive Injection Tool`);
52
- console.log(`📥 Inject autonomous configuration with prompts\n`);
53
-
54
- const args = process.argv.slice(2);
55
- let targetPath: string;
56
-
57
- const pathArg = args.find((arg) => !arg.startsWith('-'));
58
- if (pathArg) {
59
- const cleanPath = pathArg.trim().replace(/^["']|["']$/g, '');
60
- targetPath = path.resolve(cleanPath);
61
-
62
- if (!(await isValidPath(targetPath))) {
63
- console.error(`❌ Directory not found: ${targetPath}`);
64
- process.exit(1);
65
- }
66
-
67
- console.log(`📁 Using provided path: ${targetPath}`);
68
- } else {
69
- targetPath = await promptForTargetPath();
70
- }
71
-
72
- // Prevent injecting into obsidian-plugin-config itself
73
- const selfPkg = path.join(targetPath, 'package.json');
74
- if (fs.existsSync(selfPkg)) {
75
- const pkg = JSON.parse(fs.readFileSync(selfPkg, 'utf8'));
76
- if (pkg.name === 'obsidian-plugin-config') {
77
- console.error(`❌ Cannot inject into obsidian-plugin-config itself.`);
78
- process.exit(1);
79
- }
80
- }
81
-
82
- console.log(`\n🔍 Checking plugin-config repository status...`);
83
- await ensurePluginConfigClean();
84
-
85
- console.log(`\n🔍 Analyzing plugin...`);
86
- const plan = await analyzePlugin(targetPath);
87
-
88
- const confirmed = await showInjectionPlan(plan, false);
89
-
90
- if (!confirmed) {
91
- console.log(`❌ Injection cancelled by user`);
92
- process.exit(0);
93
- }
94
-
95
- await performInjection(targetPath, false);
96
- } catch (error) {
97
- console.error(`💥 Error: ${error instanceof Error ? error.message : String(error)}`);
98
- process.exit(1);
99
- } finally {
100
- rl.close();
101
- }
102
- }
103
-
104
- main().catch(console.error);
1
+ #!/usr/bin/env tsx
2
+
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import {
6
+ analyzePlugin,
7
+ ensurePluginConfigClean,
8
+ performInjection,
9
+ showInjectionPlan
10
+ } from './inject-core.js';
11
+ import {
12
+ askConfirmation,
13
+ askQuestion,
14
+ createReadlineInterface,
15
+ isValidPath
16
+ } from './utils.js';
17
+
18
+ const rl = createReadlineInterface();
19
+
20
+ async function promptForTargetPath(): Promise<string> {
21
+ console.log(`\n📁 Select target plugin directory:`);
22
+ console.log(` Common paths (copy-paste ready):`);
23
+ console.log(` - ../test-sample-plugin`);
24
+ console.log(` 💡 Tip: You can paste paths with or without quotes`);
25
+
26
+ while (true) {
27
+ const rawInput = await askQuestion(`\nEnter plugin directory path: `, rl);
28
+
29
+ if (!rawInput.trim()) {
30
+ console.log(`❌ Please enter a valid path`);
31
+ continue;
32
+ }
33
+
34
+ const cleanPath = rawInput.trim().replace(/^["']|["']$/g, '');
35
+ const resolvedPath = path.resolve(cleanPath);
36
+
37
+ if (!(await isValidPath(resolvedPath))) {
38
+ console.log(`❌ Directory not found: ${resolvedPath}`);
39
+ const retry = await askConfirmation(`Try again?`, rl);
40
+ if (!retry) throw new Error('User cancelled');
41
+ continue;
42
+ }
43
+
44
+ console.log(`📁 Target directory: ${resolvedPath}`);
45
+ return resolvedPath;
46
+ }
47
+ }
48
+
49
+ async function main(): Promise<void> {
50
+ try {
51
+ console.log(`🎯 Obsidian Plugin Config - Interactive Injection Tool`);
52
+ console.log(`📥 Inject autonomous configuration with prompts\n`);
53
+
54
+ const args = process.argv.slice(2);
55
+ let targetPath: string;
56
+
57
+ const pathArg = args.find((arg) => !arg.startsWith('-'));
58
+ if (pathArg) {
59
+ const cleanPath = pathArg.trim().replace(/^["']|["']$/g, '');
60
+ targetPath = path.resolve(cleanPath);
61
+
62
+ if (!(await isValidPath(targetPath))) {
63
+ console.error(`❌ Directory not found: ${targetPath}`);
64
+ process.exit(1);
65
+ }
66
+
67
+ console.log(`📁 Using provided path: ${targetPath}`);
68
+ } else {
69
+ targetPath = await promptForTargetPath();
70
+ }
71
+
72
+ // Prevent injecting into obsidian-plugin-config itself
73
+ const selfPkg = path.join(targetPath, 'package.json');
74
+ if (fs.existsSync(selfPkg)) {
75
+ const pkg = JSON.parse(fs.readFileSync(selfPkg, 'utf8'));
76
+ if (pkg.name === 'obsidian-plugin-config') {
77
+ console.error(`❌ Cannot inject into obsidian-plugin-config itself.`);
78
+ process.exit(1);
79
+ }
80
+ }
81
+
82
+ console.log(`\n🔍 Checking plugin-config repository status...`);
83
+ await ensurePluginConfigClean();
84
+
85
+ console.log(`\n🔍 Analyzing plugin...`);
86
+ const plan = await analyzePlugin(targetPath);
87
+
88
+ const confirmed = await showInjectionPlan(plan, false);
89
+
90
+ if (!confirmed) {
91
+ console.log(`❌ Injection cancelled by user`);
92
+ process.exit(0);
93
+ }
94
+
95
+ await performInjection(targetPath, false);
96
+ } catch (error) {
97
+ console.error(`💥 Error: ${error instanceof Error ? error.message : String(error)}`);
98
+ process.exit(1);
99
+ } finally {
100
+ rl.close();
101
+ }
102
+ }
103
+
104
+ main().catch(console.error);