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.
- package/.editorconfig +9 -14
- package/.prettierrc +3 -12
- package/README.md +8 -12
- package/bin/obsidian-inject.js +2 -10
- package/docs/INTERACTIVE_INJECTION.md +55 -116
- package/docs/LLM-GUIDE.md +17 -8
- package/eslint.config.mts +63 -64
- package/package.json +3 -4
- package/scripts/acp.ts +53 -57
- package/scripts/build-npm.ts +180 -167
- package/scripts/help.ts +3 -6
- package/scripts/inject-core.ts +765 -829
- package/scripts/inject-path.ts +144 -160
- package/scripts/inject-prompt.ts +86 -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/templates/package-sass.json +0 -5
package/scripts/acp.ts
CHANGED
|
@@ -2,78 +2,74 @@ import { execSync } from 'child_process';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
askQuestion,
|
|
6
|
+
cleanInput,
|
|
7
|
+
createReadlineInterface,
|
|
8
|
+
gitExec,
|
|
9
|
+
ensureGitSync
|
|
10
10
|
} from './utils.js';
|
|
11
11
|
|
|
12
12
|
const rl = createReadlineInterface();
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** Check if we're in the centralized config repo */
|
|
15
15
|
function isInCentralizedRepo(): boolean {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
17
|
+
if (!fs.existsSync(packageJsonPath)) return false;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
20
|
+
return packageJson.name === 'obsidian-plugin-config';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function main(): Promise<void> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
try {
|
|
25
|
+
if (process.argv.includes('-b')) {
|
|
26
|
+
console.log('Building...');
|
|
27
|
+
// For obsidian-plugin-config, just run TypeScript check
|
|
28
|
+
if (isInCentralizedRepo()) {
|
|
29
|
+
gitExec('npx tsc --noEmit');
|
|
30
|
+
} else {
|
|
31
|
+
gitExec('yarn build');
|
|
32
|
+
}
|
|
33
|
+
console.log('Build successful.');
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
+
const input: string = await askQuestion('Enter commit message: ', rl);
|
|
36
37
|
|
|
38
|
+
const cleanedInput = cleanInput(input);
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
try {
|
|
41
|
+
gitExec('git add -A');
|
|
42
|
+
gitExec(`git commit -m "${cleanedInput}"`);
|
|
43
|
+
} catch {
|
|
44
|
+
console.log('Commit already exists or failed.');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
// get current branch name
|
|
49
|
+
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
gitExec(`git commit -m "${cleanedInput}"`);
|
|
45
|
-
} catch {
|
|
46
|
-
console.log('Commit already exists or failed.');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
51
|
+
// Ensure Git is synchronized before pushing
|
|
52
|
+
await ensureGitSync();
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
gitExec(`git push --set-upstream origin ${currentBranch}`);
|
|
65
|
-
console.log('Upstream branch set and push successful.');
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Error:', error instanceof Error ? error.message : String(error));
|
|
69
|
-
} finally {
|
|
70
|
-
rl.close();
|
|
71
|
-
}
|
|
54
|
+
try {
|
|
55
|
+
gitExec(`git push origin ${currentBranch}`);
|
|
56
|
+
console.log(`Commit and push successful to origin/${currentBranch}`);
|
|
57
|
+
} catch {
|
|
58
|
+
// new branch
|
|
59
|
+
console.log(`New branch detected. Setting upstream for ${currentBranch}...`);
|
|
60
|
+
gitExec(`git push --set-upstream origin ${currentBranch}`);
|
|
61
|
+
console.log('Upstream branch set and push successful.');
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Error:', error instanceof Error ? error.message : String(error));
|
|
65
|
+
} finally {
|
|
66
|
+
rl.close();
|
|
67
|
+
}
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
main()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
.catch(console.error)
|
|
72
|
+
.finally(() => {
|
|
73
|
+
console.log('Exiting...');
|
|
74
|
+
process.exit();
|
|
75
|
+
});
|
package/scripts/build-npm.ts
CHANGED
|
@@ -8,21 +8,21 @@ import { execSync } from 'child_process';
|
|
|
8
8
|
* Generate bin/obsidian-inject.js from template
|
|
9
9
|
*/
|
|
10
10
|
async function generateBinFile(): Promise<void> {
|
|
11
|
-
|
|
11
|
+
console.log(`\nš§ Generating bin/obsidian-inject.js...`);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const binDir = 'bin';
|
|
14
|
+
const binPath = path.join(binDir, 'obsidian-inject.js');
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
// Ensure bin directory exists
|
|
17
|
+
if (!fs.existsSync(binDir)) {
|
|
18
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
19
|
+
console.log(` š Created ${binDir} directory`);
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Read package.json for version info
|
|
23
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const binContent = `#!/usr/bin/env node
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Obsidian Plugin Config - CLI Entry Point
|
|
@@ -52,19 +52,16 @@ USAGE:
|
|
|
52
52
|
obsidian-inject # Inject in current directory (with confirmation)
|
|
53
53
|
obsidian-inject <path> # Inject by path (with confirmation)
|
|
54
54
|
obsidian-inject <path> --no # Inject without confirmation
|
|
55
|
-
obsidian-inject <path> --sass # Inject with SASS support
|
|
56
55
|
obsidian-inject --help, -h # Show this help
|
|
57
56
|
|
|
58
57
|
OPTIONS:
|
|
59
58
|
--no, -n # Skip confirmation prompts (auto-confirm all)
|
|
60
|
-
--sass # Add SASS support (esbuild-sass-plugin)
|
|
61
59
|
--dry-run # Verification only (no changes)
|
|
62
60
|
|
|
63
61
|
EXAMPLES:
|
|
64
62
|
cd my-plugin && obsidian-inject
|
|
65
63
|
obsidian-inject ../my-other-plugin
|
|
66
64
|
obsidian-inject ../my-plugin --no
|
|
67
|
-
obsidian-inject ../my-plugin --sass
|
|
68
65
|
obsidian-inject "C:\\\\Users\\\\dev\\\\plugins\\\\my-plugin"
|
|
69
66
|
|
|
70
67
|
WHAT IS INJECTED:
|
|
@@ -73,7 +70,6 @@ WHAT IS INJECTED:
|
|
|
73
70
|
ā
Config files (tsconfig, eslint, prettier, vscode, github)
|
|
74
71
|
ā
Yarn protection enforced
|
|
75
72
|
ā
Automatic dependency installation
|
|
76
|
-
šØ SASS support (with --sass option): esbuild-sass-plugin + SCSS compilation
|
|
77
73
|
|
|
78
74
|
ARCHITECTURE:
|
|
79
75
|
- Plugin becomes AUTONOMOUS with local scripts
|
|
@@ -102,7 +98,6 @@ function main() {
|
|
|
102
98
|
|
|
103
99
|
// Parse arguments
|
|
104
100
|
const noConfirm = args.includes('--no') || args.includes('-n');
|
|
105
|
-
const sassFlag = args.includes('--sass');
|
|
106
101
|
const dryRun = args.includes('--dry-run');
|
|
107
102
|
const pathArg = args.find(arg => !arg.startsWith('-'));
|
|
108
103
|
|
|
@@ -117,7 +112,6 @@ function main() {
|
|
|
117
112
|
|
|
118
113
|
console.log(\`šÆ Obsidian Plugin Config - Global Injection\`);
|
|
119
114
|
console.log(\`š Target: \${targetPath}\`);
|
|
120
|
-
console.log(\`šØ SASS: \${sassFlag ? 'Enabled' : 'Disabled'}\`);
|
|
121
115
|
console.log(\`ā Confirmation: \${noConfirm ? 'Disabled (auto-confirm)' : 'Enabled'}\`);
|
|
122
116
|
console.log(\`š¦ From: \${packageRoot}\\n\`);
|
|
123
117
|
|
|
@@ -163,7 +157,6 @@ function main() {
|
|
|
163
157
|
}
|
|
164
158
|
|
|
165
159
|
// Check if tsx is available locally in target
|
|
166
|
-
let tsxCommand = 'npx tsx';
|
|
167
160
|
try {
|
|
168
161
|
execSync('npx tsx --version', {
|
|
169
162
|
cwd: targetPath,
|
|
@@ -188,10 +181,9 @@ function main() {
|
|
|
188
181
|
}
|
|
189
182
|
|
|
190
183
|
// Execute the injection script with tsx
|
|
191
|
-
const sassOption = sassFlag ? ' --sass' : '';
|
|
192
184
|
const yesOption = noConfirm ? ' --yes' : '';
|
|
193
185
|
const dryRunOption = dryRun ? ' --dry-run' : '';
|
|
194
|
-
const command = \`npx tsx "\${injectScriptPath}" "\${targetPath}"\${yesOption}\${
|
|
186
|
+
const command = \`npx tsx "\${injectScriptPath}" "\${targetPath}"\${yesOption}\${dryRunOption}\`;
|
|
195
187
|
|
|
196
188
|
execSync(command, {
|
|
197
189
|
stdio: 'inherit',
|
|
@@ -210,170 +202,191 @@ function main() {
|
|
|
210
202
|
main();
|
|
211
203
|
`;
|
|
212
204
|
|
|
213
|
-
|
|
214
|
-
|
|
205
|
+
fs.writeFileSync(binPath, binContent, 'utf8');
|
|
206
|
+
console.log(` ā
Generated ${binPath}`);
|
|
215
207
|
}
|
|
216
208
|
|
|
217
209
|
/**
|
|
218
|
-
*
|
|
210
|
+
* Ensure NPM authentication, prompting login if needed, then verifying success.
|
|
219
211
|
*/
|
|
220
212
|
async function ensureNpmAuth(): Promise<void> {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
213
|
+
console.log(`š Checking NPM authentication...`);
|
|
214
|
+
|
|
215
|
+
const checkWhoami = (): string | null => {
|
|
216
|
+
try {
|
|
217
|
+
return execSync('npm whoami --registry https://registry.npmjs.org/', {
|
|
218
|
+
stdio: 'pipe',
|
|
219
|
+
encoding: 'utf8'
|
|
220
|
+
}).trim();
|
|
221
|
+
} catch {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const whoami = checkWhoami();
|
|
227
|
+
if (whoami) {
|
|
228
|
+
console.log(` ā
Logged in as: ${whoami}\n`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
console.log(` ā ļø Not logged in to NPM`);
|
|
233
|
+
console.log(`š Please login to NPM to publish the package`);
|
|
234
|
+
console.log(` Opening browser for authentication...\n`);
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
execSync('npm login --auth-type=web --registry https://registry.npmjs.org/', {
|
|
238
|
+
stdio: 'inherit'
|
|
239
|
+
});
|
|
240
|
+
} catch {
|
|
241
|
+
console.error(`\n ā NPM login failed`);
|
|
242
|
+
console.error(` Please run 'npm login' manually and try again`);
|
|
243
|
+
throw new Error('NPM authentication required');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Verify login actually succeeded
|
|
247
|
+
const whoamiAfter = checkWhoami();
|
|
248
|
+
if (!whoamiAfter) {
|
|
249
|
+
console.error(`\n ā Login appeared to complete but authentication could not be verified`);
|
|
250
|
+
throw new Error('NPM authentication required');
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
console.log(`\n ā
Successfully logged in as: ${whoamiAfter}\n`);
|
|
245
254
|
}
|
|
246
255
|
|
|
247
256
|
/**
|
|
248
257
|
* Complete NPM workflow - Version, Commit, Push, Publish
|
|
249
258
|
*/
|
|
250
259
|
async function buildAndPublishNpm(): Promise<void> {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
260
|
+
console.log(`š Obsidian Plugin Config - NPM Publish Workflow`);
|
|
261
|
+
console.log(`Automation: version ā bin ā verify ā commit ā publish\n`);
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
// Step 0: Check NPM authentication
|
|
265
|
+
await ensureNpmAuth();
|
|
266
|
+
|
|
267
|
+
// Step 1: Update version
|
|
268
|
+
console.log(`š Step 1/5: Updating version...`);
|
|
269
|
+
execSync('tsx scripts/update-version-config.ts', { stdio: 'inherit' });
|
|
270
|
+
|
|
271
|
+
// Step 2: Generate bin file
|
|
272
|
+
console.log(`\nš§ Step 2/5: Generating bin/obsidian-inject.js...`);
|
|
273
|
+
await generateBinFile();
|
|
274
|
+
|
|
275
|
+
// Step 3: Verify package
|
|
276
|
+
console.log(`\nš Step 3/5: Verifying package...`);
|
|
277
|
+
verifyPackage();
|
|
278
|
+
|
|
279
|
+
// Step 4: Commit and push
|
|
280
|
+
console.log(`\nš¤ Step 4/5: Committing and pushing changes...`);
|
|
281
|
+
try {
|
|
282
|
+
// Add all changes
|
|
283
|
+
execSync('git add -A', { stdio: 'pipe' });
|
|
284
|
+
|
|
285
|
+
// Check if there are changes to commit
|
|
286
|
+
const status = execSync('git status --porcelain', { encoding: 'utf8' });
|
|
287
|
+
if (status.trim()) {
|
|
288
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
289
|
+
execSync(`git commit -m "Publish NPM package v${packageJson.version}"`, {
|
|
290
|
+
stdio: 'pipe'
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Get current branch and push
|
|
294
|
+
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
295
|
+
encoding: 'utf8'
|
|
296
|
+
}).trim();
|
|
297
|
+
execSync(`git push origin ${currentBranch}`, { stdio: 'inherit' });
|
|
298
|
+
console.log(` ā
Changes committed and pushed`);
|
|
299
|
+
} else {
|
|
300
|
+
console.log(` ā¹ļø No changes to commit`);
|
|
301
|
+
}
|
|
302
|
+
} catch (error) {
|
|
303
|
+
console.error(
|
|
304
|
+
` ā Commit/push failed: ${error instanceof Error ? error.message : String(error)}`
|
|
305
|
+
);
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Step 5: Publish to NPM
|
|
310
|
+
console.log(`\nš¤ Step 5/5: Publishing to NPM...`);
|
|
311
|
+
execSync('npm publish --registry https://registry.npmjs.org/', {
|
|
312
|
+
stdio: 'inherit'
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Optional: Update global CLI automatically
|
|
316
|
+
console.log(`\nš Updating global CLI...`);
|
|
317
|
+
console.log(` ā³ Waiting 30s for NPM registry propagation...`);
|
|
318
|
+
await new Promise((resolve) => setTimeout(resolve, 30000));
|
|
319
|
+
try {
|
|
320
|
+
execSync(
|
|
321
|
+
'npm install -g obsidian-plugin-config@latest --force --engine-strict=false',
|
|
322
|
+
{ stdio: 'inherit' }
|
|
323
|
+
);
|
|
324
|
+
console.log(` ā
Global CLI updated`);
|
|
325
|
+
} catch {
|
|
326
|
+
console.log(` ā ļø Global CLI update failed (NPM registry may need more time)`);
|
|
327
|
+
console.log(
|
|
328
|
+
` š” Run manually in a few minutes: npm install -g obsidian-plugin-config@latest --force`
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
console.log(`\nš Complete workflow successful!`);
|
|
332
|
+
console.log(` Test: cd any-plugin && obsidian-inject`);
|
|
333
|
+
} catch (error) {
|
|
334
|
+
console.error(
|
|
335
|
+
`\nā Workflow failed: ${error instanceof Error ? error.message : String(error)}`
|
|
336
|
+
);
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
326
339
|
}
|
|
327
340
|
|
|
328
341
|
/**
|
|
329
342
|
* Verify package is ready for publication
|
|
330
343
|
*/
|
|
331
344
|
function verifyPackage(): void {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
345
|
+
// Check required scripts
|
|
346
|
+
const requiredScripts = [
|
|
347
|
+
'scripts/inject-path.ts',
|
|
348
|
+
'scripts/inject-prompt.ts',
|
|
349
|
+
'scripts/inject-core.ts',
|
|
350
|
+
'scripts/utils.ts',
|
|
351
|
+
'scripts/acp.ts',
|
|
352
|
+
'scripts/update-version-config.ts',
|
|
353
|
+
'scripts/help.ts'
|
|
354
|
+
];
|
|
355
|
+
|
|
356
|
+
for (const script of requiredScripts) {
|
|
357
|
+
if (!fs.existsSync(script)) {
|
|
358
|
+
throw new Error(`Missing required script: ${script}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
console.log(` ā
All required scripts present`);
|
|
362
|
+
|
|
363
|
+
// Check package.json
|
|
364
|
+
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
365
|
+
const requiredFields = [
|
|
366
|
+
'name',
|
|
367
|
+
'version',
|
|
368
|
+
'description',
|
|
369
|
+
'bin',
|
|
370
|
+
'repository',
|
|
371
|
+
'author'
|
|
372
|
+
];
|
|
373
|
+
|
|
374
|
+
for (const field of requiredFields) {
|
|
375
|
+
if (!packageJson[field]) {
|
|
376
|
+
throw new Error(`Missing required package.json field: ${field}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
console.log(` ā
Package.json valid (v${packageJson.version})`);
|
|
380
|
+
|
|
381
|
+
// Check bin file exists
|
|
382
|
+
if (!fs.existsSync('bin/obsidian-inject.js')) {
|
|
383
|
+
throw new Error(`Missing bin file: bin/obsidian-inject.js`);
|
|
384
|
+
}
|
|
385
|
+
console.log(` ā
Bin file ready`);
|
|
386
|
+
|
|
387
|
+
// Quick build test
|
|
388
|
+
execSync('tsc --noEmit', { stdio: 'pipe' });
|
|
389
|
+
console.log(` ā
TypeScript check passed`);
|
|
377
390
|
}
|
|
378
391
|
|
|
379
392
|
// Run the script
|
package/scripts/help.ts
CHANGED
|
@@ -18,7 +18,6 @@ LINTING:
|
|
|
18
18
|
INJECTION (local testing):
|
|
19
19
|
yarn inject-prompt # Interactive injection
|
|
20
20
|
yarn inject-path <path> # Direct injection
|
|
21
|
-
yarn inject <path> --sass # Injection with SASS support
|
|
22
21
|
yarn check-plugin <path> # Verification only (dry-run)
|
|
23
22
|
|
|
24
23
|
NPM PUBLISHING:
|
|
@@ -43,7 +42,6 @@ PURE INJECTION TOOL:
|
|
|
43
42
|
|
|
44
43
|
templates/ ā what gets injected:
|
|
45
44
|
templates/package.json # Base deps/scripts for target plugins
|
|
46
|
-
templates/package-sass.json # Extra deps when --sass is used
|
|
47
45
|
templates/tsconfig.json # TypeScript config
|
|
48
46
|
templates/scripts/* # Scripts copied to target
|
|
49
47
|
templates/eslint.config.mts # ESLint config
|
|
@@ -55,7 +53,7 @@ inject-core.ts ā shared injection logic:
|
|
|
55
53
|
performInjection() # Main orchestration
|
|
56
54
|
|
|
57
55
|
inject-path.ts ā CLI entry point:
|
|
58
|
-
Parses --yes, --dry-run
|
|
56
|
+
Parses --yes, --dry-run flags
|
|
59
57
|
|
|
60
58
|
inject-prompt.ts ā interactive entry:
|
|
61
59
|
Prompts for target path
|
|
@@ -72,7 +70,6 @@ Development:
|
|
|
72
70
|
Global CLI Usage:
|
|
73
71
|
obsidian-inject # Inject in current dir
|
|
74
72
|
obsidian-inject ../my-plugin # Inject by path
|
|
75
|
-
obsidian-inject ../my-plugin --sass # With SASS
|
|
76
73
|
obsidian-inject --help # Show help
|
|
77
74
|
|
|
78
75
|
Local Testing:
|
|
@@ -80,10 +77,10 @@ Local Testing:
|
|
|
80
77
|
yarn inject-path ../my-plugin # Direct
|
|
81
78
|
yarn check-plugin ../my-plugin # Dry-run
|
|
82
79
|
|
|
83
|
-
SASS Support (
|
|
84
|
-
ā
esbuild-sass-plugin dependency
|
|
80
|
+
SASS Support (automatic):
|
|
85
81
|
ā
Automatic .scss detection (src/styles.scss priority)
|
|
86
82
|
ā
CSS cleanup after compilation
|
|
83
|
+
š” Install esbuild-sass-plugin manually if you use SCSS
|
|
87
84
|
|
|
88
85
|
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
89
86
|
|