obsidian-plugin-config 1.4.4 ā 1.4.6
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/.injection-info.json +5 -1
- package/.vscode/tasks.json +116 -116
- package/bin/obsidian-inject.js +1 -1
- package/package.json +3 -1
- package/scripts/acp.ts +64 -56
- package/scripts/build-npm.ts +152 -135
- package/scripts/esbuild.config.ts +221 -196
- package/scripts/inject-core.ts +613 -619
- package/scripts/inject-path.ts +144 -130
- package/scripts/inject-prompt.ts +85 -78
- package/scripts/sync-template-deps.ts +44 -44
- package/scripts/update-version-config.ts +117 -98
- package/scripts/utils.ts +121 -118
- package/templates/.vscode/settings.json +9 -9
- package/templates/.vscode/tasks.json +53 -53
- package/templates/package.json +3 -1
- package/templates/scripts/acp.ts +64 -56
- package/templates/scripts/esbuild.config.ts +268 -232
- package/templates/scripts/release.ts +78 -79
- package/templates/scripts/update-version.ts +129 -106
- package/templates/scripts/utils.ts +129 -126
- package/tsconfig.json +30 -41
- package/versions.json +3 -1
package/scripts/inject-path.ts
CHANGED
|
@@ -1,140 +1,154 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
4
|
-
import path from
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from
|
|
13
|
-
import { createReadlineInterface, isValidPath } from
|
|
6
|
+
analyzePlugin,
|
|
7
|
+
ensurePluginConfigClean,
|
|
8
|
+
findPluginConfigRoot,
|
|
9
|
+
performInjection,
|
|
10
|
+
readInjectionInfo,
|
|
11
|
+
showInjectionPlan
|
|
12
|
+
} from './inject-core.js';
|
|
13
|
+
import { createReadlineInterface, isValidPath } from './utils.js';
|
|
14
14
|
|
|
15
15
|
const rl = createReadlineInterface();
|
|
16
16
|
|
|
17
17
|
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
|
-
|
|
18
|
+
try {
|
|
19
|
+
console.log(`šÆ Obsidian Plugin Config - Local Injection Tool`);
|
|
20
|
+
console.log(`š„ Inject autonomous configuration from local files\n`);
|
|
21
|
+
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const autoConfirm = args.includes('--yes') || args.includes('-y');
|
|
24
|
+
const dryRun = args.includes('--dry-run') || args.includes('--check');
|
|
25
|
+
const useSass = args.includes('--sass');
|
|
26
|
+
const targetPath = args.find((arg) => !arg.startsWith('-'));
|
|
27
|
+
|
|
28
|
+
if (!targetPath) {
|
|
29
|
+
console.error(`ā Usage: yarn inject-path <plugin-directory> [options]`);
|
|
30
|
+
console.error(` Example: yarn inject-path ../my-obsidian-plugin`);
|
|
31
|
+
console.error(` Options:`);
|
|
32
|
+
console.error(` --yes, -y Auto-confirm injection`);
|
|
33
|
+
console.error(` --dry-run Check only (no injection)`);
|
|
34
|
+
console.error(` --sass Add esbuild-sass-plugin dependency`);
|
|
35
|
+
console.error(` Shortcuts:`);
|
|
36
|
+
console.error(` yarn check-plugin ../plugin # Verification only`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const resolvedPath = path.resolve(targetPath);
|
|
41
|
+
|
|
42
|
+
if (!(await isValidPath(resolvedPath))) {
|
|
43
|
+
console.error(`ā Directory not found: ${resolvedPath}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`š Target directory: ${resolvedPath}`);
|
|
48
|
+
console.log(`\nš Analyzing plugin...`);
|
|
49
|
+
const plan = await analyzePlugin(resolvedPath);
|
|
50
|
+
|
|
51
|
+
if (dryRun) {
|
|
52
|
+
console.log(`\nšÆ Injection Plan for: ${plan.targetPath}`);
|
|
53
|
+
console.log(`š Target: ${path.basename(plan.targetPath)}`);
|
|
54
|
+
console.log(`š¦ Package.json: ${plan.hasPackageJson ? 'ā
' : 'ā'}`);
|
|
55
|
+
console.log(`š Manifest.json: ${plan.hasManifest ? 'ā
' : 'ā'}`);
|
|
56
|
+
console.log(
|
|
57
|
+
`š Scripts folder: ${plan.hasScriptsFolder ? 'ā
(will be updated)' : 'ā (will be created)'}`
|
|
58
|
+
);
|
|
59
|
+
console.log(`š Obsidian plugin: ${plan.isObsidianPlugin ? 'ā
' : 'ā'}`);
|
|
60
|
+
console.log(
|
|
61
|
+
`šØ SASS support: ${useSass ? 'ā
(esbuild-sass-plugin will be added)' : 'ā'}`
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (!plan.isObsidianPlugin) {
|
|
65
|
+
console.log(
|
|
66
|
+
`\nā ļø Warning: This doesn't appear to be a valid Obsidian plugin`
|
|
67
|
+
);
|
|
68
|
+
console.log(` Missing manifest.json or invalid structure`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
console.log(`\nš Would inject:`);
|
|
72
|
+
console.log(
|
|
73
|
+
` ā
Local scripts (utils.ts, esbuild.config.ts, acp.ts, etc.)`
|
|
74
|
+
);
|
|
75
|
+
console.log(` ā
Updated package.json scripts`);
|
|
76
|
+
console.log(` ā
Required dependencies`);
|
|
77
|
+
console.log(
|
|
78
|
+
` š Analyze centralized imports (manual commenting may be needed)`
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const injectionInfo = readInjectionInfo(resolvedPath);
|
|
82
|
+
|
|
83
|
+
if (injectionInfo) {
|
|
84
|
+
console.log(`\nā
Status: Plugin is already injected`);
|
|
85
|
+
console.log(` š¦ Injector: ${injectionInfo.injectorName || 'unknown'}`);
|
|
86
|
+
console.log(
|
|
87
|
+
` š·ļø Version: ${injectionInfo.injectorVersion || 'unknown'}`
|
|
88
|
+
);
|
|
89
|
+
console.log(
|
|
90
|
+
` š
Date: ${
|
|
91
|
+
injectionInfo.injectionDate
|
|
92
|
+
? new Date(injectionInfo.injectionDate).toLocaleDateString()
|
|
93
|
+
: 'unknown'
|
|
94
|
+
}`
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const configRoot = findPluginConfigRoot();
|
|
98
|
+
try {
|
|
99
|
+
const configPackageJson = JSON.parse(
|
|
100
|
+
fs.readFileSync(path.join(configRoot, 'package.json'), 'utf8')
|
|
101
|
+
);
|
|
102
|
+
const currentVersion = configPackageJson.version;
|
|
103
|
+
if (
|
|
104
|
+
currentVersion &&
|
|
105
|
+
injectionInfo.injectorVersion &&
|
|
106
|
+
currentVersion !== injectionInfo.injectorVersion
|
|
107
|
+
) {
|
|
108
|
+
console.log(
|
|
109
|
+
` š Update available: ${injectionInfo.injectorVersion} ā ${currentVersion}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
// Ignore version comparison errors
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
const hasInjectedScripts = fs.existsSync(
|
|
117
|
+
path.join(resolvedPath, 'scripts', 'utils.ts')
|
|
118
|
+
);
|
|
119
|
+
if (hasInjectedScripts) {
|
|
120
|
+
console.log(`\nā ļø Status: Plugin appears to be injected (legacy)`);
|
|
121
|
+
console.log(` Found: scripts/utils.ts but no .injection-info.json`);
|
|
122
|
+
console.log(` š” Re-inject to add version tracking`);
|
|
123
|
+
} else {
|
|
124
|
+
console.log(`\nā Status: Plugin not yet injected`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
console.log(`\nš Dry-run completed - no changes made`);
|
|
129
|
+
console.log(` To inject: yarn inject ${targetPath} --yes`);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(`\nš Checking plugin-config repository status...`);
|
|
134
|
+
await ensurePluginConfigClean();
|
|
135
|
+
|
|
136
|
+
const confirmed = await showInjectionPlan(plan, autoConfirm, useSass);
|
|
137
|
+
|
|
138
|
+
if (!confirmed) {
|
|
139
|
+
console.log(`ā Injection cancelled by user`);
|
|
140
|
+
process.exit(0);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
await performInjection(resolvedPath, useSass);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error(
|
|
146
|
+
`š„ Error: ${error instanceof Error ? error.message : String(error)}`
|
|
147
|
+
);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
} finally {
|
|
150
|
+
rl.close();
|
|
151
|
+
}
|
|
138
152
|
}
|
|
139
153
|
|
|
140
154
|
main().catch(console.error);
|
package/scripts/inject-prompt.ts
CHANGED
|
@@ -1,91 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
|
-
import path from
|
|
3
|
+
import path from 'path';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from
|
|
10
|
-
import {
|
|
5
|
+
analyzePlugin,
|
|
6
|
+
ensurePluginConfigClean,
|
|
7
|
+
performInjection,
|
|
8
|
+
showInjectionPlan
|
|
9
|
+
} from './inject-core.js';
|
|
10
|
+
import {
|
|
11
|
+
askConfirmation,
|
|
12
|
+
askQuestion,
|
|
13
|
+
createReadlineInterface,
|
|
14
|
+
isValidPath
|
|
15
|
+
} from './utils.js';
|
|
11
16
|
|
|
12
17
|
const rl = createReadlineInterface();
|
|
13
18
|
|
|
14
19
|
async function promptForTargetPath(): Promise<string> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
+
console.log(`\nš Select target plugin directory:`);
|
|
21
|
+
console.log(` Common paths (copy-paste ready):`);
|
|
22
|
+
console.log(` - ../test-sample-plugin`);
|
|
23
|
+
console.log(` - ../sample-plugin-modif`);
|
|
24
|
+
console.log(` - ../my-obsidian-plugin`);
|
|
25
|
+
console.log(` š” Tip: You can paste paths with or without quotes`);
|
|
26
|
+
|
|
27
|
+
while (true) {
|
|
28
|
+
const rawInput = await askQuestion(`\nEnter plugin directory path: `, rl);
|
|
29
|
+
|
|
30
|
+
if (!rawInput.trim()) {
|
|
31
|
+
console.log(`ā Please enter a valid path`);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const cleanPath = rawInput.trim().replace(/^["']|["']$/g, '');
|
|
36
|
+
const resolvedPath = path.resolve(cleanPath);
|
|
37
|
+
|
|
38
|
+
if (!(await isValidPath(resolvedPath))) {
|
|
39
|
+
console.log(`ā Directory not found: ${resolvedPath}`);
|
|
40
|
+
const retry = await askConfirmation(`Try again?`, rl);
|
|
41
|
+
if (!retry) throw new Error('User cancelled');
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(`š Target directory: ${resolvedPath}`);
|
|
46
|
+
return resolvedPath;
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
async function main(): Promise<void> {
|
|
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
|
-
|
|
51
|
+
try {
|
|
52
|
+
console.log(`šÆ Obsidian Plugin Config - Interactive Injection Tool`);
|
|
53
|
+
console.log(`š„ Inject autonomous configuration with prompts\n`);
|
|
54
|
+
|
|
55
|
+
const args = process.argv.slice(2);
|
|
56
|
+
const useSass = args.includes('--sass');
|
|
57
|
+
let targetPath: string;
|
|
58
|
+
|
|
59
|
+
const pathArg = args.find((arg) => !arg.startsWith('-'));
|
|
60
|
+
if (pathArg) {
|
|
61
|
+
const cleanPath = pathArg.trim().replace(/^["']|["']$/g, '');
|
|
62
|
+
targetPath = path.resolve(cleanPath);
|
|
63
|
+
|
|
64
|
+
if (!(await isValidPath(targetPath))) {
|
|
65
|
+
console.error(`ā Directory not found: ${targetPath}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log(`š Using provided path: ${targetPath}`);
|
|
70
|
+
} else {
|
|
71
|
+
targetPath = await promptForTargetPath();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log(`\nš Checking plugin-config repository status...`);
|
|
75
|
+
await ensurePluginConfigClean();
|
|
76
|
+
|
|
77
|
+
console.log(`\nš Analyzing plugin...`);
|
|
78
|
+
const plan = await analyzePlugin(targetPath);
|
|
79
|
+
|
|
80
|
+
const confirmed = await showInjectionPlan(plan, false, useSass);
|
|
81
|
+
|
|
82
|
+
if (!confirmed) {
|
|
83
|
+
console.log(`ā Injection cancelled by user`);
|
|
84
|
+
process.exit(0);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
await performInjection(targetPath, useSass);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error(
|
|
90
|
+
`š„ Error: ${error instanceof Error ? error.message : String(error)}`
|
|
91
|
+
);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
} finally {
|
|
94
|
+
rl.close();
|
|
95
|
+
}
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
main().catch(console.error);
|
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
4
|
-
import path from
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
5
|
|
|
6
|
-
const TEMPLATES_PKG =
|
|
7
|
-
const TEMPLATES_SASS =
|
|
6
|
+
const TEMPLATES_PKG = 'templates/package.json';
|
|
7
|
+
const TEMPLATES_SASS = 'templates/package-sass.json';
|
|
8
8
|
|
|
9
9
|
function resolvedVersion(dep: string): string | null {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const pkgPath = path.join('node_modules', dep, 'package.json');
|
|
11
|
+
if (!fs.existsSync(pkgPath)) return null;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version as string;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function updateDeps(deps: Record<string, string>): { updated: string[] } {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
const updated: string[] = [];
|
|
21
|
+
|
|
22
|
+
for (const dep of Object.keys(deps)) {
|
|
23
|
+
const current = deps[dep];
|
|
24
|
+
// Skip wildcards like "*"
|
|
25
|
+
if (current === '*') continue;
|
|
26
|
+
|
|
27
|
+
const resolved = resolvedVersion(dep);
|
|
28
|
+
if (!resolved) continue;
|
|
29
|
+
|
|
30
|
+
// Keep "latest" as-is, update pinned/range versions
|
|
31
|
+
if (current !== 'latest') {
|
|
32
|
+
const newVersion = `^${resolved}`;
|
|
33
|
+
if (deps[dep] !== newVersion) {
|
|
34
|
+
deps[dep] = newVersion;
|
|
35
|
+
updated.push(`${dep}: ${current} ā ${newVersion}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { updated };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function syncFile(filePath: string): void {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const pkg = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
45
|
+
const { updated } = updateDeps(pkg.devDependencies ?? {});
|
|
46
|
+
|
|
47
|
+
if (updated.length) {
|
|
48
|
+
fs.writeFileSync(filePath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
49
|
+
console.log(`\nā
${filePath}`);
|
|
50
|
+
for (const u of updated) console.log(` ${u}`);
|
|
51
|
+
} else {
|
|
52
|
+
console.log(`\nā
${filePath} ā already up to date`);
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
console.log(
|
|
56
|
+
console.log('š Syncing template deps from node_modules...');
|
|
57
57
|
syncFile(TEMPLATES_PKG);
|
|
58
58
|
syncFile(TEMPLATES_SASS);
|
|
59
|
-
console.log(
|
|
59
|
+
console.log('\nā
Done.');
|