obsidian-plugin-config 1.7.3 ā 1.7.5
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/README.md +7 -7
- package/bin/obsidian-inject.js +21 -13
- package/docs/INTERACTIVE_INJECTION.md +41 -50
- package/docs/SCSS-FLOW.md +92 -88
- package/package.json +1 -1
- package/scripts/acp.ts +10 -12
- package/scripts/build-npm.ts +397 -393
- package/scripts/help.ts +87 -87
- package/scripts/inject-core.ts +870 -898
- package/scripts/inject-path.ts +157 -156
- package/scripts/inject-prompt.ts +104 -104
- package/scripts/utils.ts +173 -151
- package/templates/.vscode/tasks.json +1 -1
- package/templates/scripts/acp.ts +3 -6
- package/templates/scripts/env.ts +4 -5
- package/templates/scripts/esbuild.config.ts +1 -2
- package/templates/scripts/release.ts +14 -17
- package/templates/scripts/utils.ts +33 -17
- package/docs/audit.md +0 -39
package/scripts/inject-path.ts
CHANGED
|
@@ -1,156 +1,157 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
|
|
3
|
-
import
|
|
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
|
-
|
|
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
|
-
|
|
58
|
-
const pkg = JSON.parse(
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
console.log(
|
|
73
|
-
console.log(
|
|
74
|
-
console.log(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.log(
|
|
87
|
-
console.log(` ā
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
console.log(
|
|
95
|
-
console.log(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.log(
|
|
128
|
-
console.log(`
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
console.log(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
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 = await findPluginConfigRoot();
|
|
19
|
+
let version = 'unknown';
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(
|
|
22
|
+
await readFile(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
|
+
try {
|
|
58
|
+
const pkg = JSON.parse(await readFile(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
|
+
} catch {
|
|
64
|
+
// No package.json or unreadable - not the self case
|
|
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
|
+
|
|
81
|
+
if (!plan.isObsidianPlugin) {
|
|
82
|
+
console.log(`\nā ļø Warning: This doesn't appear to be a valid Obsidian plugin`);
|
|
83
|
+
console.log(` Missing manifest.json or invalid structure`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
console.log(`\nš Would inject:`);
|
|
87
|
+
console.log(` ā
Local scripts (utils.ts, esbuild.config.ts, acp.ts, etc.)`);
|
|
88
|
+
console.log(` ā
Updated package.json scripts`);
|
|
89
|
+
console.log(` ā
Required dependencies`);
|
|
90
|
+
|
|
91
|
+
const injectionInfo = await readInjectionInfo(resolvedPath);
|
|
92
|
+
|
|
93
|
+
if (injectionInfo) {
|
|
94
|
+
console.log(`\nā
Status: Plugin is already injected`);
|
|
95
|
+
console.log(` š¦ Injector: ${injectionInfo.injectorName || 'unknown'}`);
|
|
96
|
+
console.log(` š·ļø Version: ${injectionInfo.injectorVersion || 'unknown'}`);
|
|
97
|
+
console.log(
|
|
98
|
+
` š
Date: ${
|
|
99
|
+
injectionInfo.injectionDate
|
|
100
|
+
? new Date(injectionInfo.injectionDate).toLocaleDateString()
|
|
101
|
+
: 'unknown'
|
|
102
|
+
}`
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const configPackageJson = JSON.parse(
|
|
107
|
+
await readFile(path.join(configRoot, 'package.json'), 'utf8')
|
|
108
|
+
);
|
|
109
|
+
const currentVersion = configPackageJson.version;
|
|
110
|
+
if (
|
|
111
|
+
currentVersion &&
|
|
112
|
+
injectionInfo.injectorVersion &&
|
|
113
|
+
currentVersion !== injectionInfo.injectorVersion
|
|
114
|
+
) {
|
|
115
|
+
console.log(
|
|
116
|
+
` š Update available: ${injectionInfo.injectorVersion} ā ${currentVersion}`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
// Ignore version comparison errors
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
const hasInjectedScripts = await isValidPath(
|
|
124
|
+
path.join(resolvedPath, 'scripts', 'utils.ts')
|
|
125
|
+
);
|
|
126
|
+
if (hasInjectedScripts) {
|
|
127
|
+
console.log(`\nā ļø Status: Plugin appears to be injected (legacy)`);
|
|
128
|
+
console.log(` Found: scripts/utils.ts but no .injection-info.json`);
|
|
129
|
+
console.log(` š” Re-inject to add version tracking`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log(`\nā Status: Plugin not yet injected`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.log(`\nš Dry-run completed - no changes made`);
|
|
136
|
+
console.log(` To inject: yarn inject ${targetPath} --yes`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.log(`\nš Checking plugin-config repository status...`);
|
|
141
|
+
await ensurePluginConfigClean();
|
|
142
|
+
|
|
143
|
+
const confirmed = await showInjectionPlan(plan, autoConfirm);
|
|
144
|
+
|
|
145
|
+
if (!confirmed) {
|
|
146
|
+
console.log(`ā Injection cancelled by user`);
|
|
147
|
+
process.exit(0);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
await performInjection(resolvedPath, autoConfirm);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error(`š„ Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
main().catch(console.error);
|
package/scripts/inject-prompt.ts
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
|
|
3
|
-
import
|
|
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 (
|
|
75
|
-
const pkg = JSON.parse(
|
|
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 { readFile } from 'fs/promises';
|
|
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 (await isValidPath(selfPkg)) {
|
|
75
|
+
const pkg = JSON.parse(await readFile(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);
|