obsidian-plugin-config 1.1.0 → 1.1.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/package.json +96 -96
- package/scripts/help.ts +31 -31
- package/scripts/inject-path.ts +89 -5
- package/templates/scripts/help.ts +24 -24
- package/tsconfig.json +40 -40
- package/versions.json +4 -1
- package/docs/injection-strategy-analysis.md +0 -277
- package/src/main.ts +0 -74
package/package.json
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
2
|
+
"name": "obsidian-plugin-config",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Système d'injection pour plugins Obsidian autonomes",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"obsidian-inject": "./bin/obsidian-inject.js"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"obsidian",
|
|
13
|
+
"obsidian-plugin",
|
|
14
|
+
"typescript",
|
|
15
|
+
"injection",
|
|
16
|
+
"autonomous",
|
|
17
|
+
"cli",
|
|
18
|
+
"development-tools",
|
|
19
|
+
"plugin-utilities"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "yarn install && yarn run update-exports",
|
|
23
|
+
"update-exports": "node scripts/update-exports.js",
|
|
24
|
+
"acp": "tsx scripts/acp.ts",
|
|
25
|
+
"update-version": "tsx scripts/update-version-config.ts",
|
|
26
|
+
"v": "tsx scripts/update-version-config.ts",
|
|
27
|
+
"inject-path": "tsx scripts/inject-path.ts",
|
|
28
|
+
"inject": "tsx scripts/inject-path.ts",
|
|
29
|
+
"inject-prompt": "tsx scripts/inject-prompt.ts",
|
|
30
|
+
"check-plugin": "tsx scripts/inject-path.ts --dry-run",
|
|
31
|
+
"build-npm": "tsx scripts/build-npm.ts",
|
|
32
|
+
"publish-npm": "tsx scripts/build-npm.ts",
|
|
33
|
+
"help": "tsx scripts/help.ts",
|
|
34
|
+
"h": "tsx scripts/help.ts",
|
|
35
|
+
"lint": "eslint . --ext .ts",
|
|
36
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
37
|
+
"dev": "tsx scripts/esbuild.config.ts",
|
|
38
|
+
"build": "tsc -noEmit -skipLibCheck",
|
|
39
|
+
"real": "tsx scripts/esbuild.config.ts production real",
|
|
40
|
+
"bacp": "tsx scripts/acp.ts -b",
|
|
41
|
+
"release": "tsx scripts/release.ts",
|
|
42
|
+
"r": "tsx scripts/release.ts"
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
".": "./src/index.ts",
|
|
46
|
+
"./scripts/*": "./scripts/*",
|
|
47
|
+
"./modals": "./src/modals/index.ts",
|
|
48
|
+
"./tools": "./src/tools/index.ts",
|
|
49
|
+
"./utils": "./src/utils/index.ts"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/eslint": "latest",
|
|
53
|
+
"@types/node": "^22.15.26",
|
|
54
|
+
"@types/semver": "^7.7.0",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "latest",
|
|
56
|
+
"@typescript-eslint/parser": "latest",
|
|
57
|
+
"builtin-modules": "3.3.0",
|
|
58
|
+
"dedent": "^1.6.0",
|
|
59
|
+
"dotenv": "^16.4.5",
|
|
60
|
+
"esbuild": "latest",
|
|
61
|
+
"eslint": "latest",
|
|
62
|
+
"eslint-import-resolver-typescript": "latest",
|
|
63
|
+
"fs-extra": "^11.2.0",
|
|
64
|
+
"jiti": "latest",
|
|
65
|
+
"obsidian": "*",
|
|
66
|
+
"obsidian-typings": "^3.9.5",
|
|
67
|
+
"semver": "^7.7.2",
|
|
68
|
+
"tsx": "^4.19.4",
|
|
69
|
+
"typescript": "^5.8.2"
|
|
70
|
+
},
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@types/lodash": "^4.17.17",
|
|
73
|
+
"@types/node": "^22.15.26",
|
|
74
|
+
"@types/semver": "^7.7.0",
|
|
75
|
+
"builtin-modules": "3.3.0",
|
|
76
|
+
"dedent": "^1.6.0",
|
|
77
|
+
"dotenv": "^16.4.5",
|
|
78
|
+
"esbuild": "latest",
|
|
79
|
+
"fs-extra": "^11.2.0",
|
|
80
|
+
"lodash": "^4.17.21",
|
|
81
|
+
"obsidian": "*",
|
|
82
|
+
"obsidian-typings": "^3.9.5",
|
|
83
|
+
"semver": "^7.7.2",
|
|
84
|
+
"tsx": "^4.19.4",
|
|
85
|
+
"typescript": "^5.8.2"
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"npm": "please-use-yarn",
|
|
89
|
+
"yarn": ">=1.22.0",
|
|
90
|
+
"node": ">=16.0.0"
|
|
91
|
+
},
|
|
92
|
+
"repository": {
|
|
93
|
+
"type": "git",
|
|
94
|
+
"url": "https://github.com/3C0D/obsidian-plugin-config.git"
|
|
95
|
+
},
|
|
96
|
+
"author": "3C0D"
|
|
97
|
+
}
|
package/scripts/help.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
3
|
console.log(`
|
|
4
|
-
🎯 Obsidian Plugin Config -
|
|
5
|
-
|
|
4
|
+
🎯 Obsidian Plugin Config - Quick Help
|
|
5
|
+
Injection system for autonomous Obsidian plugins
|
|
6
6
|
|
|
7
7
|
═══════════════════════════════════════════════════════════════════
|
|
8
8
|
|
|
9
|
-
📋
|
|
9
|
+
📋 MAIN COMMANDS
|
|
10
10
|
|
|
11
11
|
INJECTION:
|
|
12
|
-
yarn inject <
|
|
13
|
-
yarn inject-prompt <
|
|
14
|
-
yarn check-plugin <
|
|
12
|
+
yarn inject <path> --yes # Automatic injection
|
|
13
|
+
yarn inject-prompt <path> # Injection with prompts
|
|
14
|
+
yarn check-plugin <path> # Verification without injection
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
yarn acp # Add, commit, push (
|
|
16
|
+
DEVELOPMENT:
|
|
17
|
+
yarn acp # Add, commit, push (with Git sync)
|
|
18
18
|
yarn bacp # Build + add, commit, push
|
|
19
|
-
yarn v, update-version #
|
|
20
|
-
yarn release, r #
|
|
21
|
-
yarn build-npm # Build package
|
|
22
|
-
yarn lint, lint:fix # ESLint
|
|
23
|
-
yarn run help, h #
|
|
19
|
+
yarn v, update-version # Update version
|
|
20
|
+
yarn release, r # GitHub release with tag
|
|
21
|
+
yarn build-npm # Build NPM package
|
|
22
|
+
yarn lint, lint:fix # ESLint verification/correction
|
|
23
|
+
yarn run help, h # This help
|
|
24
24
|
|
|
25
25
|
═══════════════════════════════════════════════════════════════════
|
|
26
26
|
|
|
27
|
-
🔧 INJECTION
|
|
27
|
+
🔧 LOCAL INJECTION
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
├── obsidian-plugin-config/ #
|
|
32
|
-
├──
|
|
33
|
-
└──
|
|
29
|
+
Recommended structure:
|
|
30
|
+
my-plugins/
|
|
31
|
+
├── obsidian-plugin-config/ # This repo
|
|
32
|
+
├── my-plugin-1/
|
|
33
|
+
└── my-plugin-2/
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
yarn inject ../
|
|
37
|
-
yarn check-plugin ../
|
|
35
|
+
Usage:
|
|
36
|
+
yarn inject ../my-plugin --yes
|
|
37
|
+
yarn check-plugin ../my-plugin # Verification only
|
|
38
38
|
|
|
39
39
|
═══════════════════════════════════════════════════════════════════
|
|
40
40
|
|
|
41
|
-
✅
|
|
41
|
+
✅ WHAT IS INJECTED
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Autonomous scripts:
|
|
44
44
|
✅ utils.ts, acp.ts, release.ts, update-version.ts
|
|
45
45
|
✅ esbuild.config.ts, help.ts
|
|
46
|
-
✅
|
|
47
|
-
✅
|
|
48
|
-
✅
|
|
46
|
+
✅ TypeScript and ESLint configuration
|
|
47
|
+
✅ GitHub Actions workflows (Yarn)
|
|
48
|
+
✅ Automatic Git sync verification
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
Result: 100% autonomous plugin, no external dependencies
|
|
51
51
|
|
|
52
52
|
═══════════════════════════════════════════════════════════════════
|
|
53
53
|
|
|
54
|
-
📦 WORKFLOW
|
|
54
|
+
📦 NPM WORKFLOW (when stable)
|
|
55
55
|
|
|
56
56
|
1. yarn build-npm # Build package
|
|
57
57
|
2. yarn v # Update version
|
|
58
|
-
3. npm publish #
|
|
58
|
+
3. npm publish # Publish (requires npm login)
|
|
59
59
|
|
|
60
|
-
VERSION
|
|
60
|
+
CURRENT VERSION: 1.0.6
|
|
61
61
|
`);
|
package/scripts/inject-path.ts
CHANGED
|
@@ -605,6 +605,87 @@ function readInjectionInfo(targetPath: string): any | null {
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Check if tsx is available and install it if needed
|
|
610
|
+
*/
|
|
611
|
+
async function ensureTsxAvailable(targetPath: string): Promise<void> {
|
|
612
|
+
console.log(`\n🔍 Checking tsx availability...`);
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
// Check if tsx is available globally
|
|
616
|
+
try {
|
|
617
|
+
execSync('tsx --version', { stdio: 'pipe' });
|
|
618
|
+
console.log(` ✅ tsx is available globally`);
|
|
619
|
+
return;
|
|
620
|
+
} catch {
|
|
621
|
+
// tsx not available globally, continue to check locally
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// Check if tsx is available locally in target
|
|
625
|
+
try {
|
|
626
|
+
execSync('npx tsx --version', {
|
|
627
|
+
cwd: targetPath,
|
|
628
|
+
stdio: 'pipe'
|
|
629
|
+
});
|
|
630
|
+
console.log(` ✅ tsx is available locally`);
|
|
631
|
+
return;
|
|
632
|
+
} catch {
|
|
633
|
+
// tsx not available locally, need to install
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
console.log(` ⚠️ tsx not found, installing as dev dependency...`);
|
|
637
|
+
|
|
638
|
+
// Install tsx as dev dependency
|
|
639
|
+
execSync('yarn add -D tsx', {
|
|
640
|
+
cwd: targetPath,
|
|
641
|
+
stdio: 'inherit'
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
console.log(` ✅ tsx installed successfully`);
|
|
645
|
+
|
|
646
|
+
} catch (error) {
|
|
647
|
+
console.error(` ❌ Failed to install tsx: ${error}`);
|
|
648
|
+
console.log(` 💡 You may need to install tsx manually: yarn add -D tsx`);
|
|
649
|
+
throw new Error('tsx installation failed');
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Check if tsx is installed locally and install it if needed
|
|
655
|
+
*/
|
|
656
|
+
async function ensureTsxInstalled(targetPath: string): Promise<void> {
|
|
657
|
+
console.log(`\n🔍 Checking tsx installation...`);
|
|
658
|
+
|
|
659
|
+
const packageJsonPath = path.join(targetPath, "package.json");
|
|
660
|
+
|
|
661
|
+
try {
|
|
662
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
663
|
+
const devDependencies = packageJson.devDependencies || {};
|
|
664
|
+
const dependencies = packageJson.dependencies || {};
|
|
665
|
+
|
|
666
|
+
// Check if tsx is already installed
|
|
667
|
+
if (devDependencies.tsx || dependencies.tsx) {
|
|
668
|
+
console.log(` ✅ tsx is already installed`);
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
console.log(` ⚠️ tsx not found, installing as dev dependency...`);
|
|
673
|
+
|
|
674
|
+
// Install tsx as dev dependency
|
|
675
|
+
execSync('yarn add -D tsx', {
|
|
676
|
+
cwd: targetPath,
|
|
677
|
+
stdio: 'inherit'
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
console.log(` ✅ tsx installed successfully`);
|
|
681
|
+
|
|
682
|
+
} catch (error) {
|
|
683
|
+
console.error(` ❌ Failed to install tsx: ${error}`);
|
|
684
|
+
console.log(` 💡 You may need to install tsx manually: yarn add -D tsx`);
|
|
685
|
+
throw new Error('tsx installation failed');
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
608
689
|
/**
|
|
609
690
|
* Run yarn install in target directory
|
|
610
691
|
*/
|
|
@@ -630,21 +711,24 @@ export async function performInjection(targetPath: string): Promise<void> {
|
|
|
630
711
|
console.log(`\n🚀 Starting injection process...`);
|
|
631
712
|
|
|
632
713
|
try {
|
|
633
|
-
// Step 1:
|
|
714
|
+
// Step 1: Ensure tsx is installed
|
|
715
|
+
await ensureTsxInstalled(targetPath);
|
|
716
|
+
|
|
717
|
+
// Step 2: Inject scripts
|
|
634
718
|
await injectScripts(targetPath);
|
|
635
719
|
|
|
636
|
-
// Step
|
|
720
|
+
// Step 3: Update package.json
|
|
637
721
|
console.log(`\n📦 Updating package.json...`);
|
|
638
722
|
await updatePackageJson(targetPath);
|
|
639
723
|
|
|
640
|
-
// Step
|
|
724
|
+
// Step 4: Analyze centralized imports (without modifying)
|
|
641
725
|
await analyzeCentralizedImports(targetPath);
|
|
642
726
|
|
|
643
|
-
// Step
|
|
727
|
+
// Step 5: Create required directories
|
|
644
728
|
console.log(`\n📁 Creating required directories...`);
|
|
645
729
|
await createRequiredDirectories(targetPath);
|
|
646
730
|
|
|
647
|
-
// Step
|
|
731
|
+
// Step 6: Install dependencies
|
|
648
732
|
await runYarnInstall(targetPath);
|
|
649
733
|
|
|
650
734
|
// Step 6: Create injection info file
|
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
2
|
|
|
3
3
|
console.log(`
|
|
4
|
-
🎯 Obsidian Plugin -
|
|
5
|
-
|
|
4
|
+
🎯 Obsidian Plugin - Quick Help
|
|
5
|
+
Available commands in this autonomous plugin
|
|
6
6
|
|
|
7
7
|
═══════════════════════════════════════════════════════════════════
|
|
8
8
|
|
|
9
|
-
📋
|
|
9
|
+
📋 MAIN COMMANDS
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
DEVELOPMENT:
|
|
12
12
|
yarn start # Install dependencies + start dev
|
|
13
|
-
yarn dev # Build dev mode
|
|
13
|
+
yarn dev # Build dev mode with hot reload
|
|
14
14
|
yarn build # Build production
|
|
15
|
-
yarn real # Build + install
|
|
16
|
-
yarn lint, lint:fix # ESLint
|
|
15
|
+
yarn real # Build + install in real vault
|
|
16
|
+
yarn lint, lint:fix # ESLint verification/correction
|
|
17
17
|
|
|
18
18
|
VERSION & RELEASE:
|
|
19
19
|
yarn v, update-version # Update version (package.json + manifest.json)
|
|
20
|
-
yarn release, r # Create GitHub release
|
|
20
|
+
yarn release, r # Create GitHub release with tag
|
|
21
21
|
|
|
22
22
|
GIT OPERATIONS:
|
|
23
|
-
yarn acp # Add, commit, push (
|
|
23
|
+
yarn acp # Add, commit, push (with Git sync)
|
|
24
24
|
yarn bacp # Build + add, commit, push
|
|
25
|
-
yarn run help, h #
|
|
25
|
+
yarn run help, h # This help
|
|
26
26
|
|
|
27
27
|
═══════════════════════════════════════════════════════════════════
|
|
28
28
|
|
|
29
|
-
🚀 WORKFLOW
|
|
29
|
+
🚀 TYPICAL WORKFLOW
|
|
30
30
|
|
|
31
|
-
1. yarn start #
|
|
32
|
-
2. yarn dev #
|
|
33
|
-
3. yarn build # Test build
|
|
31
|
+
1. yarn start # Initial setup
|
|
32
|
+
2. yarn dev # Daily development
|
|
33
|
+
3. yarn build # Test production build
|
|
34
34
|
4. yarn v # Update version
|
|
35
|
-
5. yarn release #
|
|
35
|
+
5. yarn release # Publish GitHub release
|
|
36
36
|
|
|
37
37
|
═══════════════════════════════════════════════════════════════════
|
|
38
38
|
|
|
39
39
|
⚙️ CONFIGURATION
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
41
|
+
ENVIRONMENT:
|
|
42
|
+
- Edit .env to define TEST_VAULT and REAL_VAULT
|
|
43
|
+
- Autonomous scripts (no external dependencies)
|
|
44
|
+
- Automatic Git sync verification before push
|
|
45
45
|
|
|
46
|
-
PLUGIN
|
|
47
|
-
✅
|
|
48
|
-
✅
|
|
49
|
-
✅
|
|
50
|
-
✅
|
|
46
|
+
AUTONOMOUS PLUGIN:
|
|
47
|
+
✅ Independent local scripts
|
|
48
|
+
✅ Integrated TypeScript and ESLint configuration
|
|
49
|
+
✅ GitHub Actions workflows with Yarn
|
|
50
|
+
✅ No dependency on obsidian-plugin-config
|
|
51
51
|
`);
|
package/tsconfig.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"types": [
|
|
4
|
-
"obsidian-typings"
|
|
5
|
-
],
|
|
6
|
-
"paths": {
|
|
7
|
-
"obsidian-typings/implementations": [
|
|
8
|
-
"./node_modules/obsidian-typings/dist/implementations.d.ts",
|
|
9
|
-
"./node_modules/obsidian-typings/dist/implementations.cjs"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"inlineSourceMap": true,
|
|
13
|
-
"inlineSources": true,
|
|
14
|
-
"module": "NodeNext",
|
|
15
|
-
"moduleResolution": "NodeNext",
|
|
16
|
-
"target": "ES2021",
|
|
17
|
-
"allowJs": true,
|
|
18
|
-
"noImplicitAny": true,
|
|
19
|
-
"importHelpers": true,
|
|
20
|
-
"isolatedModules": true,
|
|
21
|
-
"allowImportingTsExtensions": true,
|
|
22
|
-
"noEmit": true,
|
|
23
|
-
"allowSyntheticDefaultImports": true,
|
|
24
|
-
"verbatimModuleSyntax": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true,
|
|
26
|
-
"strictNullChecks": true,
|
|
27
|
-
"resolveJsonModule": true,
|
|
28
|
-
"lib": [
|
|
29
|
-
"DOM",
|
|
30
|
-
"ES2021"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
"include": [
|
|
34
|
-
"./src/**/*.ts",
|
|
35
|
-
"./scripts/**/*.ts"
|
|
36
|
-
],
|
|
37
|
-
"exclude": [
|
|
38
|
-
"node_modules",
|
|
39
|
-
"eslint.config.ts"
|
|
40
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"types": [
|
|
4
|
+
"obsidian-typings"
|
|
5
|
+
],
|
|
6
|
+
"paths": {
|
|
7
|
+
"obsidian-typings/implementations": [
|
|
8
|
+
"./node_modules/obsidian-typings/dist/implementations.d.ts",
|
|
9
|
+
"./node_modules/obsidian-typings/dist/implementations.cjs"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"inlineSourceMap": true,
|
|
13
|
+
"inlineSources": true,
|
|
14
|
+
"module": "NodeNext",
|
|
15
|
+
"moduleResolution": "NodeNext",
|
|
16
|
+
"target": "ES2021",
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
"noImplicitAny": true,
|
|
19
|
+
"importHelpers": true,
|
|
20
|
+
"isolatedModules": true,
|
|
21
|
+
"allowImportingTsExtensions": true,
|
|
22
|
+
"noEmit": true,
|
|
23
|
+
"allowSyntheticDefaultImports": true,
|
|
24
|
+
"verbatimModuleSyntax": true,
|
|
25
|
+
"forceConsistentCasingInFileNames": true,
|
|
26
|
+
"strictNullChecks": true,
|
|
27
|
+
"resolveJsonModule": true,
|
|
28
|
+
"lib": [
|
|
29
|
+
"DOM",
|
|
30
|
+
"ES2021"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"include": [
|
|
34
|
+
"./src/**/*.ts",
|
|
35
|
+
"./scripts/**/*.ts"
|
|
36
|
+
],
|
|
37
|
+
"exclude": [
|
|
38
|
+
"node_modules",
|
|
39
|
+
"eslint.config.ts"
|
|
40
|
+
]
|
|
41
41
|
}
|
package/versions.json
CHANGED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
# Analyse des Stratégies d'Injection - Plugins Obsidian
|
|
2
|
-
|
|
3
|
-
## Vue d'ensemble
|
|
4
|
-
|
|
5
|
-
Ce document analyse les différentes approches d'injection de code et de configuration pour les plugins Obsidian, en comparant notre système actuel avec les solutions existantes.
|
|
6
|
-
|
|
7
|
-
## 1. Notre Approche Actuelle (obsidian-plugin-config)
|
|
8
|
-
|
|
9
|
-
### Stratégie : Injection Dure + Package NPM
|
|
10
|
-
|
|
11
|
-
**Principe :**
|
|
12
|
-
|
|
13
|
-
- **Injection locale** : Copie physique des fichiers depuis `templates/` vers le plugin cible
|
|
14
|
-
- **Package NPM global** : `obsidian-inject` pour injection depuis n'importe où
|
|
15
|
-
- **Autonomie complète** : Aucune dépendance externe après injection
|
|
16
|
-
|
|
17
|
-
**Architecture :**
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
obsidian-plugin-config/
|
|
21
|
-
├── templates/ # Templates à injecter
|
|
22
|
-
│ ├── scripts/ # Scripts de build/dev
|
|
23
|
-
│ ├── eslint.config.mts
|
|
24
|
-
│ └── tsconfig-template.json
|
|
25
|
-
├── src/ # Modules réutilisables (actuels)
|
|
26
|
-
│ ├── modals/ # GenericConfirmModal
|
|
27
|
-
│ ├── utils/ # NoticeHelper, SettingsHelper
|
|
28
|
-
│ └── tools/ # (vide actuellement)
|
|
29
|
-
└── scripts/ # Scripts d'injection
|
|
30
|
-
├── inject-path.ts
|
|
31
|
-
└── inject-prompt.ts
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**Avantages :**
|
|
35
|
-
|
|
36
|
-
- ✅ Autonomie totale après injection
|
|
37
|
-
- ✅ Pas de dépendances externes
|
|
38
|
-
- ✅ Contrôle total sur les versions
|
|
39
|
-
- ✅ Fonctionne offline
|
|
40
|
-
|
|
41
|
-
**Inconvénients :**
|
|
42
|
-
|
|
43
|
-
- ❌ Duplication de code entre plugins
|
|
44
|
-
- ❌ Mise à jour manuelle (re-injection)
|
|
45
|
-
- ❌ Modules src/ non utilisés (injection dure uniquement)
|
|
46
|
-
|
|
47
|
-
## 2. Approche mnaoumov
|
|
48
|
-
|
|
49
|
-
### Stratégie : Generator + Package NPM + Imports
|
|
50
|
-
|
|
51
|
-
**Architecture :**
|
|
52
|
-
|
|
53
|
-
1. **generator-obsidian-plugin** : Yeoman generator pour créer des plugins
|
|
54
|
-
2. **obsidian-dev-utils** : Package NPM avec utilitaires importables
|
|
55
|
-
3. **obsidian-sample-plugin-extended** : Template de référence
|
|
56
|
-
|
|
57
|
-
**Principe :**
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
// Dans le plugin généré
|
|
61
|
-
import { someHelper } from "obsidian-dev-utils";
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Package obsidian-dev-utils :**
|
|
65
|
-
|
|
66
|
-
- CLI commands (build, lint, etc.)
|
|
67
|
-
- Helper functions (importables)
|
|
68
|
-
- Setting components
|
|
69
|
-
- Modals
|
|
70
|
-
- Debugging tools
|
|
71
|
-
|
|
72
|
-
**Avantages :**
|
|
73
|
-
|
|
74
|
-
- ✅ Mise à jour automatique via NPM
|
|
75
|
-
- ✅ Pas de duplication de code
|
|
76
|
-
- ✅ Écosystème riche (Svelte, React, SASS)
|
|
77
|
-
- ✅ Maintenance centralisée
|
|
78
|
-
|
|
79
|
-
**Inconvénients :**
|
|
80
|
-
|
|
81
|
-
- ❌ Dépendance externe permanente
|
|
82
|
-
- ❌ Risque de breaking changes
|
|
83
|
-
- ❌ Nécessite connexion pour updates
|
|
84
|
-
|
|
85
|
-
## 3. Approche Officielle (obsidian-sample-plugin)
|
|
86
|
-
|
|
87
|
-
### Stratégie : Template Simple
|
|
88
|
-
|
|
89
|
-
**Principe :**
|
|
90
|
-
|
|
91
|
-
- Template minimal fourni par Obsidian
|
|
92
|
-
- Fork/clone + modification manuelle
|
|
93
|
-
- Aucun système d'injection
|
|
94
|
-
|
|
95
|
-
**Avantages :**
|
|
96
|
-
|
|
97
|
-
- ✅ Simplicité maximale
|
|
98
|
-
- ✅ Contrôle total
|
|
99
|
-
|
|
100
|
-
**Inconvénients :**
|
|
101
|
-
|
|
102
|
-
- ❌ Pas de réutilisabilité
|
|
103
|
-
- ❌ Maintenance manuelle
|
|
104
|
-
- ❌ Pas d'évolution
|
|
105
|
-
|
|
106
|
-
## 4. Comparaison des Stratégies
|
|
107
|
-
|
|
108
|
-
| Aspect | Notre Approche | mnaoumov | Officiel |
|
|
109
|
-
| ------------------- | ------------------- | ---------------- | -------- |
|
|
110
|
-
| **Réutilisabilité** | Moyenne (templates) | Élevée (imports) | Faible |
|
|
111
|
-
| **Autonomie** | Totale | Dépendante | Totale |
|
|
112
|
-
| **Maintenance** | Manuelle | Automatique | Manuelle |
|
|
113
|
-
| **Complexité** | Moyenne | Élevée | Faible |
|
|
114
|
-
| **Évolutivité** | Bonne | Excellente | Limitée |
|
|
115
|
-
|
|
116
|
-
## 5. Problématique Actuelle
|
|
117
|
-
|
|
118
|
-
### Modules src/ Non Exploités
|
|
119
|
-
|
|
120
|
-
Nous avons des modules dans `src/` (modals, utils) mais ils ne sont pas utilisés car :
|
|
121
|
-
|
|
122
|
-
- L'injection est "dure" (copie de fichiers)
|
|
123
|
-
- Pas d'imports depuis le package NPM
|
|
124
|
-
- Système d'exports automatique non exploité
|
|
125
|
-
|
|
126
|
-
### Questions Stratégiques
|
|
127
|
-
|
|
128
|
-
1. **Faut-il passer aux imports NPM ?**
|
|
129
|
-
|
|
130
|
-
- Avantages : Réutilisabilité, maintenance centralisée
|
|
131
|
-
- Inconvénients : Dépendance externe, complexité
|
|
132
|
-
|
|
133
|
-
2. **Faut-il garder l'injection dure ?**
|
|
134
|
-
|
|
135
|
-
- Avantages : Autonomie, simplicité
|
|
136
|
-
- Inconvénients : Duplication, maintenance manuelle
|
|
137
|
-
|
|
138
|
-
3. **Approche hybride possible ?**
|
|
139
|
-
- Templates pour la structure (injection dure)
|
|
140
|
-
- Modules pour le code réutilisable (imports NPM)
|
|
141
|
-
|
|
142
|
-
## 6. Recommandations Stratégiques
|
|
143
|
-
|
|
144
|
-
### Option A : Hybride (Recommandée)
|
|
145
|
-
|
|
146
|
-
- **Templates** : Scripts, configuration (injection dure)
|
|
147
|
-
- **Modules** : Composants réutilisables (imports NPM)
|
|
148
|
-
- **Avantage** : Meilleur des deux mondes
|
|
149
|
-
|
|
150
|
-
### Option B : Full NPM (comme mnaoumov)
|
|
151
|
-
|
|
152
|
-
- Tout en imports NPM
|
|
153
|
-
- Dépendance externe acceptée
|
|
154
|
-
- Maintenance centralisée
|
|
155
|
-
|
|
156
|
-
### Option C : Full Injection (actuel)
|
|
157
|
-
|
|
158
|
-
- Tout en injection dure
|
|
159
|
-
- Déplacer src/ vers templates/
|
|
160
|
-
- Autonomie maximale
|
|
161
|
-
|
|
162
|
-
## 7. Découvertes de l'Historique
|
|
163
|
-
|
|
164
|
-
### Ancienne Approche (Trouvée dans obsidian-sample-plugin-modif)
|
|
165
|
-
|
|
166
|
-
**Imports NPM découverts :**
|
|
167
|
-
|
|
168
|
-
```javascript
|
|
169
|
-
// Dans src/test-centralized-utils.ts (commenté)
|
|
170
|
-
import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
**Configuration package.json (ancienne) :**
|
|
174
|
-
|
|
175
|
-
```json
|
|
176
|
-
{
|
|
177
|
-
"dependencies": {
|
|
178
|
-
"obsidian-plugin-config": "file:../obsidian-plugin-config"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Exports dans obsidian-plugin-config :**
|
|
184
|
-
|
|
185
|
-
```json
|
|
186
|
-
{
|
|
187
|
-
"exports": {
|
|
188
|
-
"./modals": "./src/modals/index.ts",
|
|
189
|
-
"./utils": "./src/utils/index.ts",
|
|
190
|
-
"./tools": "./src/tools/index.ts"
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Transition Observée
|
|
196
|
-
|
|
197
|
-
1. **Avant** : Imports NPM depuis obsidian-plugin-config
|
|
198
|
-
2. **Maintenant** : Injection dure + modules copiés localement
|
|
199
|
-
3. **Résultat** : Duplication des modules (src/ dans les deux repos)
|
|
200
|
-
|
|
201
|
-
### Pattern d'Utilisation Identifié
|
|
202
|
-
|
|
203
|
-
```javascript
|
|
204
|
-
// Utilisation typique (avant)
|
|
205
|
-
import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
206
|
-
import { GenericConfirmModal } from "obsidian-plugin-config/modals";
|
|
207
|
-
|
|
208
|
-
// Dans le plugin
|
|
209
|
-
NoticeHelper.success("✅ Action réussie !");
|
|
210
|
-
new GenericConfirmModal(this.app, options).open();
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## 8. Prochaines Étapes
|
|
214
|
-
|
|
215
|
-
1. ✅ **Analyser l'historique** - FAIT : Trouvé les anciens imports NPM
|
|
216
|
-
2. **Décider de la stratégie** : Hybride vs Full NPM vs Full Injection
|
|
217
|
-
3. **Tester l'approche choisie** sur un plugin pilote
|
|
218
|
-
4. **Implémenter la solution finale**
|
|
219
|
-
|
|
220
|
-
### Recommandation Mise à Jour
|
|
221
|
-
|
|
222
|
-
**Option A : Retour aux Imports NPM (Recommandée)**
|
|
223
|
-
|
|
224
|
-
- Réactiver les exports dans package.json
|
|
225
|
-
- Permettre `import { NoticeHelper } from "obsidian-plugin-config/utils"`
|
|
226
|
-
- Garder l'injection dure pour les scripts/config
|
|
227
|
-
- **Avantage** : Pas de duplication, maintenance centralisée
|
|
228
|
-
|
|
229
|
-
## 9. État Actuel (Mise à Jour)
|
|
230
|
-
|
|
231
|
-
### ✅ Découvertes Positives
|
|
232
|
-
|
|
233
|
-
**Infrastructure déjà en place :**
|
|
234
|
-
|
|
235
|
-
- ✅ Exports configurés dans package.json
|
|
236
|
-
- ✅ Script update-exports.js fonctionnel
|
|
237
|
-
- ✅ Modules src/ complets (modals, utils, tools)
|
|
238
|
-
- ✅ Index.ts auto-généré
|
|
239
|
-
|
|
240
|
-
**Test réussi sur test-sample-plugin :**
|
|
241
|
-
|
|
242
|
-
```javascript
|
|
243
|
-
// Imports fonctionnels
|
|
244
|
-
import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
245
|
-
import { GenericConfirmModal } from "obsidian-plugin-config/modals";
|
|
246
|
-
|
|
247
|
-
// Configuration package.json
|
|
248
|
-
"obsidian-plugin-config": "file:../obsidian-plugin-config"
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
### 🎯 Prochaines Étapes Immédiates
|
|
252
|
-
|
|
253
|
-
1. ✅ **Test local** - FAIT : Imports fonctionnent en local
|
|
254
|
-
2. **Test NPM** - Publier version avec exports et tester
|
|
255
|
-
3. **Migration plugins existants** - Ajouter imports aux plugins actuels
|
|
256
|
-
4. **Documentation** - Documenter l'usage hybride
|
|
257
|
-
|
|
258
|
-
### 🔄 Workflow Recommandé
|
|
259
|
-
|
|
260
|
-
**Phase 1 : Test Local (En Cours)**
|
|
261
|
-
|
|
262
|
-
- Injection dure + dépendance locale `file:../obsidian-plugin-config`
|
|
263
|
-
- Validation des imports sur plugins de test
|
|
264
|
-
|
|
265
|
-
**Phase 2 : Package NPM**
|
|
266
|
-
|
|
267
|
-
- Publier obsidian-plugin-config avec exports
|
|
268
|
-
- Tester `obsidian-inject` + imports NPM
|
|
269
|
-
|
|
270
|
-
**Phase 3 : Migration**
|
|
271
|
-
|
|
272
|
-
- Migrer plugins existants vers approche hybride
|
|
273
|
-
- Documentation complète
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
_Document créé pour clarifier la stratégie d'injection d'obsidian-plugin-config_
|
package/src/main.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Plugin, Notice } from "obsidian";
|
|
2
|
-
import { NoticeHelper } from "obsidian-plugin-config/utils";
|
|
3
|
-
import { GenericConfirmModal } from "obsidian-plugin-config/modals";
|
|
4
|
-
|
|
5
|
-
export default class TestSamplePlugin extends Plugin {
|
|
6
|
-
async onload() {
|
|
7
|
-
console.log("🔌 Test Sample Plugin loaded");
|
|
8
|
-
|
|
9
|
-
// Test NoticeHelper import
|
|
10
|
-
NoticeHelper.success("✅ Plugin chargé avec imports NPM !");
|
|
11
|
-
|
|
12
|
-
// Commande pour tester NoticeHelper
|
|
13
|
-
this.addCommand({
|
|
14
|
-
id: 'test-notice-helper',
|
|
15
|
-
name: 'Test NoticeHelper Import',
|
|
16
|
-
callback: () => {
|
|
17
|
-
NoticeHelper.info("📢 Test NoticeHelper depuis obsidian-plugin-config");
|
|
18
|
-
NoticeHelper.success("✅ Import NoticeHelper fonctionne !");
|
|
19
|
-
NoticeHelper.warning("⚠️ Ceci est un warning");
|
|
20
|
-
NoticeHelper.error("❌ Ceci est une erreur (test)");
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Commande pour tester GenericConfirmModal
|
|
25
|
-
this.addCommand({
|
|
26
|
-
id: 'test-confirm-modal',
|
|
27
|
-
name: 'Test Confirm Modal Import',
|
|
28
|
-
callback: () => {
|
|
29
|
-
new GenericConfirmModal(this.app, {
|
|
30
|
-
title: "Test Import Modal",
|
|
31
|
-
message: "Ce modal vient d'obsidian-plugin-config via import NPM. Ça fonctionne ?",
|
|
32
|
-
confirmText: "Oui, parfait !",
|
|
33
|
-
cancelText: "Non, problème",
|
|
34
|
-
onConfirm: () => {
|
|
35
|
-
NoticeHelper.success("🎉 Modal confirmé ! Les imports fonctionnent !");
|
|
36
|
-
},
|
|
37
|
-
onCancel: () => {
|
|
38
|
-
NoticeHelper.warning("😞 Modal annulé");
|
|
39
|
-
}
|
|
40
|
-
}).open();
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// Commande combinée pour test complet
|
|
45
|
-
this.addCommand({
|
|
46
|
-
id: 'test-all-imports',
|
|
47
|
-
name: 'Test All Imports',
|
|
48
|
-
callback: () => {
|
|
49
|
-
NoticeHelper.info("🧪 Test complet des imports...");
|
|
50
|
-
|
|
51
|
-
setTimeout(() => {
|
|
52
|
-
new GenericConfirmModal(this.app, {
|
|
53
|
-
title: "Test Complet",
|
|
54
|
-
message: "Tous les imports d'obsidian-plugin-config fonctionnent-ils correctement ?",
|
|
55
|
-
confirmText: "Tout fonctionne !",
|
|
56
|
-
cancelText: "Il y a des problèmes",
|
|
57
|
-
onConfirm: () => {
|
|
58
|
-
NoticeHelper.success("🎯 Parfait ! Système d'imports validé !");
|
|
59
|
-
console.log("✅ Test complet réussi - imports obsidian-plugin-config OK");
|
|
60
|
-
},
|
|
61
|
-
onCancel: () => {
|
|
62
|
-
NoticeHelper.error("❌ Problème détecté dans les imports");
|
|
63
|
-
console.error("❌ Test complet échoué");
|
|
64
|
-
}
|
|
65
|
-
}).open();
|
|
66
|
-
}, 1000);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
onunload() {
|
|
72
|
-
console.log("🔌 Test Sample Plugin unloaded");
|
|
73
|
-
}
|
|
74
|
-
}
|