obsidian-plugin-config 1.6.17 ā 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 -169
- package/scripts/inject-core.ts +835 -823
- package/scripts/inject-path.ts +151 -165
- 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/inject-path.ts
CHANGED
|
@@ -3,174 +3,160 @@
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
analyzePlugin,
|
|
7
|
+
ensurePluginConfigClean,
|
|
8
|
+
findPluginConfigRoot,
|
|
9
|
+
performInjection,
|
|
10
|
+
readInjectionInfo,
|
|
11
|
+
showInjectionPlan
|
|
12
12
|
} from './inject-core.js';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
const rl = createReadlineInterface();
|
|
13
|
+
import { isValidPath } from './utils.js';
|
|
16
14
|
|
|
17
15
|
async function main(): Promise<void> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
process.exit(0);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
await performInjection(resolvedPath, autoConfirm, useSass);
|
|
166
|
-
} catch (error) {
|
|
167
|
-
console.error(
|
|
168
|
-
`š„ Error: ${error instanceof Error ? error.message : String(error)}`
|
|
169
|
-
);
|
|
170
|
-
process.exit(1);
|
|
171
|
-
} finally {
|
|
172
|
-
rl.close();
|
|
173
|
-
}
|
|
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(`\nā ļø Warning: This doesn't appear to be a valid Obsidian plugin`);
|
|
86
|
+
console.log(` Missing manifest.json or invalid structure`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
console.log(`\nš Would inject:`);
|
|
90
|
+
console.log(` ā
Local scripts (utils.ts, esbuild.config.ts, acp.ts, etc.)`);
|
|
91
|
+
console.log(` ā
Updated package.json scripts`);
|
|
92
|
+
console.log(` ā
Required dependencies`);
|
|
93
|
+
console.log(` š Analyze centralized imports (manual commenting may be needed)`);
|
|
94
|
+
|
|
95
|
+
const injectionInfo = readInjectionInfo(resolvedPath);
|
|
96
|
+
|
|
97
|
+
if (injectionInfo) {
|
|
98
|
+
console.log(`\nā
Status: Plugin is already injected`);
|
|
99
|
+
console.log(` š¦ Injector: ${injectionInfo.injectorName || 'unknown'}`);
|
|
100
|
+
console.log(` š·ļø Version: ${injectionInfo.injectorVersion || 'unknown'}`);
|
|
101
|
+
console.log(
|
|
102
|
+
` š
Date: ${
|
|
103
|
+
injectionInfo.injectionDate
|
|
104
|
+
? new Date(injectionInfo.injectionDate).toLocaleDateString()
|
|
105
|
+
: 'unknown'
|
|
106
|
+
}`
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const configRoot = findPluginConfigRoot();
|
|
110
|
+
try {
|
|
111
|
+
const configPackageJson = JSON.parse(
|
|
112
|
+
fs.readFileSync(path.join(configRoot, 'package.json'), 'utf8')
|
|
113
|
+
);
|
|
114
|
+
const currentVersion = configPackageJson.version;
|
|
115
|
+
if (
|
|
116
|
+
currentVersion &&
|
|
117
|
+
injectionInfo.injectorVersion &&
|
|
118
|
+
currentVersion !== injectionInfo.injectorVersion
|
|
119
|
+
) {
|
|
120
|
+
console.log(
|
|
121
|
+
` š Update available: ${injectionInfo.injectorVersion} ā ${currentVersion}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
} catch {
|
|
125
|
+
// Ignore version comparison errors
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
const hasInjectedScripts = fs.existsSync(
|
|
129
|
+
path.join(resolvedPath, 'scripts', 'utils.ts')
|
|
130
|
+
);
|
|
131
|
+
if (hasInjectedScripts) {
|
|
132
|
+
console.log(`\nā ļø Status: Plugin appears to be injected (legacy)`);
|
|
133
|
+
console.log(` Found: scripts/utils.ts but no .injection-info.json`);
|
|
134
|
+
console.log(` š” Re-inject to add version tracking`);
|
|
135
|
+
} else {
|
|
136
|
+
console.log(`\nā Status: Plugin not yet injected`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.log(`\nš Dry-run completed - no changes made`);
|
|
141
|
+
console.log(` To inject: yarn inject ${targetPath} --yes`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
console.log(`\nš Checking plugin-config repository status...`);
|
|
146
|
+
await ensurePluginConfigClean();
|
|
147
|
+
|
|
148
|
+
const confirmed = await showInjectionPlan(plan, autoConfirm, useSass);
|
|
149
|
+
|
|
150
|
+
if (!confirmed) {
|
|
151
|
+
console.log(`ā Injection cancelled by user`);
|
|
152
|
+
process.exit(0);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
await performInjection(resolvedPath, autoConfirm, useSass);
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error(`š„ Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
174
160
|
}
|
|
175
161
|
|
|
176
162
|
main().catch(console.error);
|
package/scripts/inject-prompt.ts
CHANGED
|
@@ -3,107 +3,105 @@
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
analyzePlugin,
|
|
7
|
+
ensurePluginConfigClean,
|
|
8
|
+
performInjection,
|
|
9
|
+
showInjectionPlan
|
|
10
10
|
} from './inject-core.js';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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(` - ../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
|
+
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async function main(): Promise<void> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
rl.close();
|
|
106
|
-
}
|
|
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(`š„ Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
} finally {
|
|
103
|
+
rl.close();
|
|
104
|
+
}
|
|
107
105
|
}
|
|
108
106
|
|
|
109
107
|
main().catch(console.error);
|