obsidian-plugin-config 1.6.18 → 1.7.1

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